From 2c52286c4090e49663949b82bf8ddf35ea9b362c Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 30 Apr 2015 20:12:21 +0000 Subject: [PATCH] Correct the tag merge script logic The previous iteration did not take into account that the most recent tag on master is likely to have been a release candidate, and therefore have the same major+minor value as the incoming release. Also tags pushed to non-stable branches should be skipped. Change-Id: I339df1d88ddaedb193b1b246a2c21a433c11495c --- jenkins/scripts/merge_tags.sh | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/jenkins/scripts/merge_tags.sh b/jenkins/scripts/merge_tags.sh index bbbafef667..0c9f2485df 100755 --- a/jenkins/scripts/merge_tags.sh +++ b/jenkins/scripts/merge_tags.sh @@ -14,16 +14,16 @@ TAG=$1 -# Avoid acting on any tag which is not strictly an all-numeric/stops string -# since the logic below relies on a simple numeric sort. Ordering of -# non-numeric strings are locale-specific, and situations like PEP-440 violate -# assumptions about non-numeric versions being alpha-sorted anyway. This check -# is redundant since we should never allow a tag containing non-numeric version -# components through the filter for the release pipeline in Zuul, but is here -# as a safeguard to validate that expectation since "Git tags are forever." -if ! echo $TAG|grep '^[0-9\.]*$'; then - echo "ERROR: Triggered on non-release $TAG tag." - exit 1 +# Only merge release tag if it's on a stable branch +if ! $(git branch -r --contains "$TAG" | grep "stable/" >/dev/null); then + echo "Tag $TAG was not pushed to a stable branch, ignoring." + exit 0 +fi + +# Make sure the tag does not correspond to a patch release +if ! echo $TAG|grep '^[0-9]\+\.[0-9]\+\(\.0\|\)$'; then + echo "Triggered on patch release $TAG tag, ignoring." + exit 0 fi git config user.name "OpenStack Proposal Bot" @@ -37,15 +37,9 @@ git reset --hard origin/master MASTER_MINOR=`git describe|cut -d. -f-2` TAG_MINOR=`echo $TAG|cut -d. -f-2` -# If the tag is for a patch version where its minor matches master's, skip -if [ "$MASTER_MINOR" = "$TAG_MINOR" ]; then - echo "Skipping $TAG which shares master's $MASTER_MINOR version." - exit 0 -fi - # If the tag is for an earlier version than master's, skip if [ "$(echo $(echo -e "$MASTER_MINOR\n$TAG_MINOR"|sort -V))" \ - = "$TAG_MINOR $MASTER_MINOR" ]; then + \!= "$MASTER_MINOR $TAG_MINOR" ]; then echo "Skipping $TAG which sorts before master's $MASTER_MINOR version." exit 0 fi