From 329f9a0e999ffbe0f15d22e6800406b5134a3c51 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 27 Mar 2015 19:11:08 -0400 Subject: [PATCH] Do not allow minor release which is not a decendant of the release branch This does some git magic to make sure you do not tag a branch with v0.13.3 unless that branch is a decendant of the release-0.13 branch upstream. Don't allow v0.13.4 if v0.13.3 doesn't exit Don't allow v0.13.3 if v0.13.3 already exits --- build/mark-new-version.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/build/mark-new-version.sh b/build/mark-new-version.sh index 8b37e0c11a8..f227fa0bddc 100755 --- a/build/mark-new-version.sh +++ b/build/mark-new-version.sh @@ -48,8 +48,29 @@ release_branch="release-${VERSION_MAJOR}.${VERSION_MINOR}" current_branch=$(git rev-parse --abbrev-ref HEAD) if [[ "${VERSION_PATCH}" != "0" ]]; then - if [[ ${current_branch} != "${release_branch}" ]]; then - echo "!!! You are trying to tag to an existing minor release but are not on the release branch: ${release_branch}" + # sorry, no going back in time, pull latest from upstream + git remote update > /dev/null 2>&1 + + if git ls-remote --tags --exit-code git@github.com:GoogleCloudPlatform/kubernetes.git refs/tags/${NEW_VERSION} > /dev/null; then + echo "!!! You are trying to tag ${NEW_VERSION} but it already exists. Stop it!" + exit 1 + fi + + last_version="v${VERSION_MAJOR}.${VERSION_MINOR}.$((VERSION_PATCH-1))" + if ! git ls-remote --tags --exit-code git@github.com:GoogleCloudPlatform/kubernetes.git refs/tags/${last_version} > /dev/null; then + echo "!!! You are trying to tag ${NEW_VERSION} but ${last_version} doesn't even exist!" + exit 1 + fi + + # this is rather magic. This checks that HEAD is a descendant of the github branch release-x.y + branches=$(git branch --contains $(git ls-remote --heads git@github.com:GoogleCloudPlatform/kubernetes.git refs/heads/${release_branch} | cut -f1) ${current_branch}) + if [[ $? -ne 0 ]]; then + echo "!!! git failed, I dunno...." + exit 1 + fi + + if [[ ${branches} != "* ${current_branch}" ]]; then + echo "!!! You are trying to tag to an existing minor release but branch: ${release_branch} is not an ancestor of ${current_branch}" exit 1 fi fi @@ -93,6 +114,7 @@ if [[ "${VERSION_PATCH}" == "0" ]]; then git branch "${release_branch}" fi +echo "" echo "Success you must now:" echo "" echo "- Push the tag:"