check submodule updates when task.subupdates is set

This commit is contained in:
southerntofu 2020-09-16 14:42:21 +02:00
parent d41c474275
commit fcb60d97b9
1 changed files with 60 additions and 41 deletions

View File

@ -226,12 +226,14 @@ for p_name in ${PROJECTS[*]}; do
debug already_cloned
cd "$p_dir"
# Refresh remote before comparing with local
git fetch --quiet origin
if ! git fetch --quiet origin; then
error pull_failed
exit 1
fi
git diff --quiet remotes/origin/$p_branch
if [[ $? != 0 ]]; then
info pull
# Update all submodules, for now only when the main repo changed (TODO)
if ! git pull --quiet --recurse-submodules; then
if ! git pull --quiet; then #--recurse-submodules; then
error pull_failed
exit 1
fi
@ -240,9 +242,26 @@ for p_name in ${PROJECTS[*]}; do
elif [[ $FORCE = 1 ]]; then
debug forcing
run $p_name
else
# No update on the primary branch, but maybe there's a submodule update?
if [ -f $BASEDIR/$p_name.subupdates ]; then
git submodule foreach --recursive 'if ! git fetch --quiet origin; then\
error pull_failed\
exit 1\
fi\
git diff --quiet remotes/origin/$(git rev-parse --abbrev-ref HEAD)\
if [[ $? != 0 ]]; then\
info pull\
if ! git pull --quiet; then\
error pull_failed\
exit 1\
fi\
fi'
run $p_name
else
debug no_update
fi
fi
done
# Check the PID in lockfile is still ours, we don't want