summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan S. Arnold <ryan.arnold@linaro.org>2016-10-12 15:19:12 -0500
committerRyan S. Arnold <ryan.arnold@linaro.org>2016-10-13 17:12:16 -0500
commit7552cee0afeb84f45ef2d1cfa860a62b974a3808 (patch)
tree7bea0385c5586f8e851400c44b646f61383743ad
parent85bd4cd17ce50780c23fa632f955efb5a435f126 (diff)
Runs tracking rc/rel tags need to checkout release branch
If the user specifies that a new rc or release run is to track a previous release-candidate or release tag then the script needs to know that it instead needs to track the head of the release branch. The user should specify tags so that the scripting knows what the next in the series is supposed to be. The release branch needs to be checked out so that there isn't a merge conflict with the rc or release bump commit, because the tracked tag will not contain the bump, and a push would cause a merge conflict. A merge conflict would cause a merge commit that would cause tags to not accurately represent the release branch. Change-Id: I48f5c1a84e208fa632005fced0853e14e2e6d8ac
-rwxr-xr-xtcwg-release.sh59
1 files changed, 56 insertions, 3 deletions
diff --git a/tcwg-release.sh b/tcwg-release.sh
index 5be06c2..40fe077 100755
--- a/tcwg-release.sh
+++ b/tcwg-release.sh
@@ -696,6 +696,62 @@ elif (( VERBOSITY >= 3 )); then
set -x;
fi
+# If the REMOTE hasn't been specified, default to 'origin'.
+: ${REMOTE:=origin}
+
+# Release-Candidates and Releases are both pushed to the release branch
+# since there is a strict linear progression from candidates to releases.
+#
+# If the user is tracking a release tag or candidate tag to build a new
+# candidate or release, we need to checkout from the release branch and not the
+# tag so that we don't get merge conflicts with a previous rc 'bump' when the
+# new series is pushed, or miss a cherry-picked patch on the release branch.
+# The following is a merge-conflict due to checking out linaro-6.1-2018.08-rc2
+# from the linaro-6.1-2016.08-rc1 tag:
+#
+# linaro-local/releases/linaro-6.1-2016.08
+# o - Backport Commit
+# o - FSF Branch Merge Commit
+# o - Snapshot Version Commit
+# o - -rc1 Version Commit <--- [TAG] linaro-6.1-2016.08-rc1
+# o - -rc2~dev Version Bump Commit |
+# o - Cherry-Picked Patch Commit +-- releases/linaro-6.1-2016.08-rc2
+# o - Backport Commit
+# ^ o - FSF Branch Merge Commit
+# | o - Snapshot Version Commit
+# | o - -rc1 Version Commit
+# | linaro-6.1-2016.08-rc2 [TAG] ---> o - -rc2 Version Commit
+# |
+# +- merge conflict & merge commit <--- git push
+#
+# Pushing release/linaro-6.1-2016.08-rc2 onto the remote
+# linaro-local/releases/linaro-6.1-2016.08 release branch will cause a merge
+# conflict between the "-rc2 Version Commit", "-rc2~dev Version Bump Commit",
+# and the "Cherry-Picked Patch Commit". While a merge commit could be pushed
+# to the linaro-local/releases/linaro-6.1-2016.08 remote branch, the newly
+# created linaro-6.1-2016.08-rc2 tag would not represent an accurate view of the
+# remote branch head.
+#
+# The correct behavior is use the tag to determine the correct release branch
+# and checkout a working branch (releases/linaro-6.2-2016.08-rc2) from that and
+# not the tag.
+if [ "${CANDIDATE:+set}" = "set" ] || [ "${RELEASE:+set}" = "set" ]; then
+ # We only redirect track to a branch if the tag being tracked is not
+ # a snapshot tag.
+ if [ "${TAG:+set}" = "set" ] && [ `echo $TAG | grep -c "snapshot"` -lt 1 ]; then
+
+ # The git -r switch denotes that we only want remote branches that a tag
+ # lives on. We then have to grep for '${REMOTE}' because users might
+ # have more than one remote (e.g., an additional 'gerrit' remote) or have
+ # a remote named something other than 'origin'. The tag might show up on
+ # more than one branch so we restrict to the first branch we find.
+ BRANCH="`git branch -r --contains ${TAG} | grep -m 1 ${REMOTE}`"
+ # Remove leading whitespace
+ BRANCH="${BRANCH#"${BRANCH%%[![:space:]]*}"}"
+ unset TAG
+ fi
+fi
+
# Track either the BRANCH or the TAG
track="${BRANCH:+${BRANCH}}${TAG:+${TAG}}"
@@ -714,9 +770,6 @@ save_branch="$(git rev-parse --abbrev-ref HEAD)"
# Test to make sure the branch or tag exists
git rev-parse --abbrev-ref $track &>/dev/null || die "${TAG:+Tag }${BRANCH:+Branch }\"$track\" doesn't exist."
-# If the REMOTE hasn't been specified, default to 'origin'.
-: ${REMOTE:=origin}
-
if [[ x"$(git remote -v | grep "${REMOTE}")" = x ]]; then
die "remote ${REMOTE} is not in your git repository."
fi