Better checking for tags when cloning puppet modules

One of the puppet modules changed tags from "2.0" to "v2.1" which I
missed.  The testing was rather unhelpful ... when "2.1" didn't exist
it went ahead and left it checked out on master and then ran the test
suite against that.  So it was quite confusing as to what the root
cause was.

Do a more thorough check of the wanted tag; if it's not there at
checkout time, abort.

Change-Id: Ic358857c56c0b5a95f1052c21bfb89e17a9816cc
This commit is contained in:
Ian Wienand 2017-12-11 16:09:47 +11:00 committed by Jens Harbott (frickler)
parent 26b07daa5b
commit 661e91a2fe

View File

@ -113,9 +113,20 @@ for MOD in ${!SOURCE_MODULES[*]} ; do
exit $clone_error
fi
fi
# make sure the correct revision is installed, I have to use rev-list b/c rev-parse does not work with tags
if [ `${GIT_CMD_BASE} rev-list HEAD --max-count=1` != `${GIT_CMD_BASE} rev-list ${SOURCE_MODULES[$MOD]} --max-count=1` ]; then
# make sure the correct revision is installed, I have to use
# rev-list b/c rev-parse does not work with tags
current_head=$(${GIT_CMD_BASE} rev-list HEAD --max-count=1)
wanted_head=$(${GIT_CMD_BASE} rev-list ${SOURCE_MODULES[$MOD]} --max-count=1)
if [[ -z ${wanted_head} ]]; then
echo "Could not find wanted revision: ${SOURCE_MODULES[$MOD]}"
echo " (did you specify a non-existant tag?)"
exit 1
fi
if [[ ${current_head} != ${wanted_head} ]]; then
# checkout correct revision
$GIT_CMD_BASE checkout ${SOURCE_MODULES[$MOD]}
fi
done