check_submodules.sh handle CI forced update only if directory exists

This commit is contained in:
Daniel Agar 2017-12-15 09:54:03 -05:00
parent cebe7add8b
commit 868ff42f47

View File

@ -3,8 +3,17 @@
function check_git_submodule { function check_git_submodule {
# The .git exists in a submodule if init and update have been done. # The .git exists in a submodule if init and update have been done.
if [ "$CI" != "true" ] && [[ -f $1"/.git" || -d $1"/.git" ]]; if [[ -f $1"/.git" || -d $1"/.git" ]];
then then
if [ "$CI" == "true" ];
then
git submodule sync --recursive -- $1
git submodule update --init --recursive --force -- $1 || true
git submodule update --init --recursive --force -- $1
exit 0
fi
SUBMODULE_STATUS=$(git submodule summary "$1") SUBMODULE_STATUS=$(git submodule summary "$1")
STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1") STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1")
if ! [[ -z "$STATUSRETVAL" ]]; if ! [[ -z "$STATUSRETVAL" ]];
@ -35,8 +44,8 @@ then
elif [ "$user_cmd" == "u" ] elif [ "$user_cmd" == "u" ]
then then
git submodule sync --recursive -- $1 git submodule sync --recursive -- $1
git submodule update --init --recursive --force --quiet -- $1 || true git submodule update --init --recursive -- $1 || true
git submodule update --init --recursive -- $1 git submodule update --init --recursive --force -- $1
echo "Submodule fixed, continuing build.." echo "Submodule fixed, continuing build.."
else else
echo "Build aborted." echo "Build aborted."
@ -44,9 +53,9 @@ then
fi fi
fi fi
else else
git submodule sync --recursive -- $1 git submodule sync --recursive --quiet -- $1
git submodule update --init --recursive --force -- $1 || true git submodule update --init --recursive -- $1 || true
git submodule update --init --recursive --force -- $1 git submodule update --init --recursive -- $1
fi fi
} }