마이크로서비스 개발 & 서브모듈 적용을 하고 가장 번거로운 점은
공통적인 변경이 발생했을 때 git add, commit & push
를
최대 서브모듈의 개수 + 1 번을 해야한다는 점입니다.
현재 진행하고 있는 프로젝트의 경우는 10번...
단순 작업은 너무 싫어요...
왠지 git submodule foreach
로 해결할 수 있을 것 같네요.
변경사항을 한 번에 git 반영합시다.
git.sh
#!/bin/bash
#!/bin/bash
msg=$@
if [[ -z "$msg" ]]; then
echo "Error: commit message not provided"
exit 1
fi;
echo "======== Submodule Repo Update ========";
echo "msg: $msg" | git submodule foreach --recursive \
'if [[ $(git status --porcelain) ]]; then \
echo "msg: '"$msg"'" && \
git add . && git commit -m "'"$msg"'" && git push; \
fi;' || :
echo "\n======== Main Repo Update ========"
if [[ $(git status --porcelain) ]]; then \
git add . && git commit -m "$@" && git push; \
fi || :
package.json
"scripts": {
...
"git": "sh ./scripts/submodule/git.sh"
},
run
npm run git "<commit message>"
result