From 6a5df80bda7a9924c0cdc921a8d6aee0dc0f0af3 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Fri, 28 Aug 2015 11:51:37 +0100 Subject: [PATCH] Fix latest_release hash test Obtain the version and latest_release tag commit hashes before changing into the cloned repository so that all tagging and pushing happens on the outer repository. --- bin/release | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/release b/bin/release index e577468f..e7378019 100755 --- a/bin/release +++ b/bin/release @@ -36,7 +36,9 @@ setup() { esac LATEST_TAG_SHA=$(git rev-parse $LATEST_TAG) + LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG) LATEST_RELEASE_SHA=$(git rev-parse latest_release) + LATEST_RELEASE_COMMIT_SHA=$(git rev-list -1 latest_release) VERSION=${LATEST_TAG} # NB does not check that this tag is on master RELEASE_DIR=./releases/$LATEST_TAG @@ -185,8 +187,10 @@ publish() { else echo "** Release draft detected" echo "== Sanity checks" - if ! [ $(git rev-list -1 $LATEST_TAG) == $(git rev-list -1 latest_release) ]; then - echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" + if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ] ; then + echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2 + echo "You may need to" >&2 + echo -e "\tgit tag -af latest_release $LATEST_TAG" >&2 exit 1 fi @@ -195,8 +199,7 @@ publish() { echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2 echo -e "\thttps://github.com/$GITHUB_USER/weave/tags" >&2 echo "You may need to" >&2 - echo -e "\tgit tag -af latest_release" - echo -e "\tgit push -f git@github.com:$GITHUB_USER/weave latest_release" + echo -e "\tgit push -f git@github.com:$GITHUB_USER/weave latest_release" >&2 exit 1 fi echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/weave:$VERSION