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
This commit is contained in:
Jeremy Stanley 2015-04-30 20:12:21 +00:00
parent 10e728cfed
commit 2c52286c40

View File

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