From 306e2381ecabb8251345dac76c160462225726a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C5=91d=20Ill=C3=A9s?= Date: Thu, 27 Apr 2023 17:12:36 +0200 Subject: [PATCH] Prevent recreate EOL'd branch In case a branch is End of Life (marked with either $series-eol or bugfix--eol) and was deleted before, then our script recreates it based on the info in deliverable's yaml file. This patch extends the script by checking if an *-eol tag exists and in case it does then exits without creating again the already deleted branch. Change-Id: I1b763aa52703221d211156c060b8998282fcfc5d --- .../files/release-tools/make_branch.sh | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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 ad8690801e..1929acd18f 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 @@ -26,6 +26,12 @@ if [[ $# -lt 3 ]]; then exit 2 fi +function cleanup_and_exit { + cd ../.. + rm -rf $MYTMPDIR + exit 0 +} + TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $TOOLSDIR/functions @@ -43,11 +49,21 @@ setup_temp_space branch-$PROJECT-$branch_as_path_entry clone_repo $REPO cd $REPO +# Skip branch creation in case bugfix--eol tag exists +if $(git tag | grep ${NEW_BRANCH/\//-}-eol > /dev/null); then + echo "A ${NEW_BRANCH/\//-}-eol tag already exists !" + cleanup_and_exit +fi + +# Skip branch creation in case -eol tag exists +if $(git tag | grep ${NEW_BRANCH#stable/}-eol >/dev/null); then + echo "A ${NEW_BRANCH#stable/}-eol tag already exists !" + cleanup_and_exit +fi + if $(git branch -r | grep $NEW_BRANCH > /dev/null); then echo "A $NEW_BRANCH branch already exists !" - cd ../.. - rm -rf $MYTMPDIR - exit 0 + cleanup_and_exit fi # NOTE(dhellmann): We wait to set up git-review until after we have