2016-01-12 05:14:15 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function check_git_submodule {
|
|
|
|
|
2016-02-23 11:16:04 -04:00
|
|
|
# The .git exists in a submodule if init and update have been done.
|
2017-12-15 10:54:03 -04:00
|
|
|
if [[ -f $1"/.git" || -d $1"/.git" ]];
|
2016-04-17 16:30:38 -03:00
|
|
|
then
|
2017-12-15 10:54:03 -04:00
|
|
|
|
2018-09-23 12:37:32 -03:00
|
|
|
# CI environment always force update everything
|
2017-12-15 10:54:03 -04:00
|
|
|
if [ "$CI" == "true" ];
|
|
|
|
then
|
2018-09-23 12:37:32 -03:00
|
|
|
git submodule --quiet sync --recursive -- $1
|
|
|
|
git submodule --quiet update --init --recursive --force -- $1 || true
|
|
|
|
git submodule --quiet update --init --recursive --force -- $1
|
2017-12-15 10:54:03 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-01-12 05:14:15 -04:00
|
|
|
SUBMODULE_STATUS=$(git submodule summary "$1")
|
2016-02-12 19:50:06 -04:00
|
|
|
STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1")
|
2016-03-11 07:07:26 -04:00
|
|
|
if ! [[ -z "$STATUSRETVAL" ]];
|
|
|
|
then
|
2016-01-12 05:33:24 -04:00
|
|
|
echo -e "\033[31mChecked $1 submodule, ACTION REQUIRED:\033[0m"
|
2016-01-12 05:14:15 -04:00
|
|
|
echo ""
|
2016-02-12 19:50:06 -04:00
|
|
|
echo -e "Different commits:"
|
2016-01-12 05:33:24 -04:00
|
|
|
echo -e "$SUBMODULE_STATUS"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
echo -e " *******************************************************************************"
|
|
|
|
echo -e " * \033[31mIF YOU DID NOT CHANGE THIS FILE (OR YOU DON'T KNOW WHAT A SUBMODULE IS):\033[0m *"
|
|
|
|
echo -e " * \033[31mHit 'u' and <ENTER> to update ALL submodules and resolve this.\033[0m *"
|
2016-03-03 08:42:13 -04:00
|
|
|
echo -e " * (performs \033[94mgit submodule sync --recursive\033[0m *"
|
|
|
|
echo -e " * and \033[94mgit submodule update --init --recursive\033[0m ) *"
|
2016-01-12 05:33:24 -04:00
|
|
|
echo -e " *******************************************************************************"
|
2016-01-12 05:14:15 -04:00
|
|
|
echo ""
|
|
|
|
echo ""
|
2016-01-12 05:33:24 -04:00
|
|
|
echo -e " Only for EXPERTS:"
|
|
|
|
echo -e " $1 submodule is not in the recommended version."
|
|
|
|
echo -e " Hit 'y' and <ENTER> to continue the build with this version. Hit <ENTER> to resolve manually."
|
|
|
|
echo -e " Use \033[94mgit add $1 && git commit -m 'Updated $1'\033[0m to choose this version (careful!)"
|
2016-01-12 05:14:15 -04:00
|
|
|
echo ""
|
|
|
|
read user_cmd
|
|
|
|
if [ "$user_cmd" == "y" ]
|
|
|
|
then
|
|
|
|
echo "Continuing build with manually overridden submodule.."
|
2017-01-07 19:55:45 -04:00
|
|
|
elif [ "$user_cmd" == "u" ]
|
|
|
|
then
|
2017-11-21 21:22:48 -04:00
|
|
|
git submodule sync --recursive -- $1
|
2017-12-15 10:54:03 -04:00
|
|
|
git submodule update --init --recursive -- $1 || true
|
|
|
|
git submodule update --init --recursive --force -- $1
|
2017-01-07 19:55:45 -04:00
|
|
|
echo "Submodule fixed, continuing build.."
|
2016-01-12 05:14:15 -04:00
|
|
|
else
|
2017-01-07 19:55:45 -04:00
|
|
|
echo "Build aborted."
|
|
|
|
exit 1
|
2016-01-12 05:14:15 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
2018-09-23 12:37:32 -03:00
|
|
|
git submodule --quiet sync --recursive --quiet -- $1
|
|
|
|
git submodule --quiet update --init --recursive -- $1 || true
|
|
|
|
git submodule --quiet update --init --recursive -- $1
|
2016-01-12 05:14:15 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-12-12 19:58:56 -04:00
|
|
|
# If called with a path then respect $GIT_SUBMODULES_ARE_EVIL but do normal processing
|
|
|
|
if [ "$#" != "0" ];
|
|
|
|
then
|
2017-11-21 21:22:48 -04:00
|
|
|
# called with a path then process only that path but respect $GIT_SUBMODULES_ARE_EVIL
|
2016-12-12 19:58:56 -04:00
|
|
|
[ -n "$GIT_SUBMODULES_ARE_EVIL" ] && {
|
|
|
|
# GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules updated
|
2017-01-07 19:55:45 -04:00
|
|
|
exit 0
|
2016-12-12 19:58:56 -04:00
|
|
|
}
|
|
|
|
|
2017-12-10 18:43:09 -04:00
|
|
|
check_git_submodule $1
|
2016-01-12 05:14:15 -04:00
|
|
|
|
2016-12-12 19:58:56 -04:00
|
|
|
else
|
2016-01-21 02:16:25 -04:00
|
|
|
|
2016-12-12 19:58:56 -04:00
|
|
|
[ -n "$GIT_SUBMODULES_ARE_EVIL" ] && {
|
2017-01-07 19:55:45 -04:00
|
|
|
# GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules updated
|
|
|
|
echo "GIT_SUBMODULES_ARE_EVIL is defined - Skipping All submodule checking!"
|
|
|
|
exit 0
|
2016-12-12 19:58:56 -04:00
|
|
|
}
|
|
|
|
|
2017-12-10 18:43:09 -04:00
|
|
|
submodules=$(git submodule status | awk '{ print $2 }')
|
2017-01-07 19:55:45 -04:00
|
|
|
for i in $submodules;
|
|
|
|
do
|
|
|
|
check_git_submodule $i
|
|
|
|
done
|
|
|
|
|
2016-12-12 19:58:56 -04:00
|
|
|
fi
|
2017-11-21 21:22:48 -04:00
|
|
|
|
|
|
|
exit 0
|