From 65d3be0cdb4809bd33b309f186c06f10778160aa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 12 Jun 2018 10:37:56 -0400 Subject: [PATCH] be more resilient in make_branch.sh for retired repositories Retired repositories may not have a .gitreview file in master, so we want to check out the tag we are given to branch from instead. There's no point in setting up git-review if we aren't going to create the branch, so move the setup logic after the test for the existing branch. Change-Id: Ie8c69a9729e5e0d470c8a9292da999e275c9611a Signed-off-by: Doug Hellmann --- .../files/release-tools/make_branch.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/copy-release-tools-scripts/files/release-tools/make_branch.sh b/roles/copy-release-tools-scripts/files/release-tools/make_branch.sh index 9bdf6363b8..a1880d97f7 100755 --- a/roles/copy-release-tools-scripts/files/release-tools/make_branch.sh +++ b/roles/copy-release-tools-scripts/files/release-tools/make_branch.sh @@ -41,7 +41,6 @@ branch_as_path_entry=$(echo $NEW_BRANCH | sed -s 's|/|-|g') setup_temp_space branch-$PROJECT-$branch_as_path_entry clone_repo $REPO cd $REPO -LANG=C git review -s if $(git branch -r | grep $NEW_BRANCH > /dev/null); then echo "A $NEW_BRANCH branch already exists !" @@ -50,6 +49,13 @@ if $(git branch -r | grep $NEW_BRANCH > /dev/null); then exit 0 fi +# NOTE(dhellmann): We wait to set up git-review until after we have +# checked for the branch and then check out the tagged point to create +# the branch in case the master branch has been retired since then and +# there is no longer a .gitreview file there. +LANG=C git checkout $START_POINT +LANG=C git review -s + echo "Creating $NEW_BRANCH from $START_POINT" git branch $NEW_BRANCH $START_POINT REALSHA=`git show-ref -s $NEW_BRANCH`