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 <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-06-12 10:37:56 -04:00
parent 465df69850
commit 65d3be0cdb

View File

@ -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`