From 661e91a2fe3279596e01f97b53d80f4b45cd1eb4 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 11 Dec 2017 16:09:47 +1100 Subject: [PATCH] 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 --- install_modules.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/install_modules.sh b/install_modules.sh index 5d5acd9c1f..b9dcb6aab3 100755 --- a/install_modules.sh +++ b/install_modules.sh @@ -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