diff options
author | Shyam <srangana@redhat.com> | 2017-04-05 14:22:57 -0400 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2017-04-10 05:09:59 -0400 |
commit | 788def7912c68616849748678574c60a52021e3c (patch) | |
tree | 7b2475c5d65f1342d2ec86161aa1cf19bf4eebd0 /rfc.sh | |
parent | b1764275341884e12ff3186681d6718f98e1096f (diff) |
scripts: Update rfc.sh to check existance of Change-Id in backports
Addition to this script is a no-op on master.
This would need to be backported to active release branches to be
effective.
This check is not smart proof, in that someone could proceed knowing
that the Change-Id differs from master, but this is not expected to
catch that, instead it is to serve more as a reminder that we need
the same Change-Id across branches.
Contributors not using rfc.sh would not see this, but they are few
and possibly far in between. Also contributors using gerrit to
cherry-pick changes will not see this. For both cases a server side
solution to catch any changes are needed.
There is a possiblilty that we will follow this up with a check
on the gerrit end and add a comment to the reviews, to aid reviewers
to quickly check the sanity of the Change-Id when it differs.
Change-Id: I11e371489a4a3cf2ff96d9892256986cd535998b
BUG: 1428047
Signed-off-by: Shyam <srangana@redhat.com>
Reviewed-on: https://review.gluster.org/17004
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'rfc.sh')
-rwxr-xr-x | rfc.sh | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -46,6 +46,72 @@ is_num() [ -z "$(echo $num | sed -e 's/[0-9]//g')" ] } +backport_id_message() +{ + echo "" + echo "This commit is to a non-master branch, and hence is treated as a backport." + echo "" + echo "For backports we would like to retain the same gerrit Change-Id across" + echo "branches. On auto inspection it is found that a gerrit Change-Id is" + echo "missing, or the Change-Id is not found on your local master" + echo "" + echo "This could mean a few things:" + echo " 1. This is not a backport, hence choose Y on the prompt to proceed" + echo " 2. Your origin master is not up to date, hence the script is unable" + echo " to find the corresponding Change-Id on master. Either choose N," + echo " 'git fetch', and try again, OR if you are sure you used the" + echo " same Change-Id, choose Y at the prompt to proceed" + echo " 3. You commented or removed the Change-Id in your commit message after" + echo " cherry picking the commit. Choose N, fix the commit message to" + echo " use the same Change-Id as master (git commit --amend), resubmit" + echo "" +} + +check_backport() +{ + moveon='N' + + # Backports are never made to master + if [ $branch = "master" ]; then + return; + fi + + # Extract the change ID from the commit message + changeid=$(git show --format='%b' | grep -i '^Change-Id: ' | awk '{print $2}') + + # If there is no change ID ask if we should continue + if [ -z "$changeid" ]; then + backport_id_message; + echo -n "Did not find a Change-Id for a possible backport. Continue (y/N): " + read moveon + else + # Search master for the same change ID (rebase_changes has run, so we + # should never not find a Change-Id) + mchangeid=$(git log origin/master --format='%b' --grep="^Change-Id: ${changeid}" | grep ${changeid} | awk '{print $2}') + + # Check if we found the change ID on master, else throw a message to + # decide if we should continue. + # NOTE: If master was not rebased, we will not find the Change-ID and + # could hit a false positive case here (or if someone checks out some + # other branch as master). + if [ $mchangeid = $changeid ]; then + moveon="Y" + else + backport_id_message; + echo "Change-Id of commit: $changeid" + echo "Change-Id on master: $mchangeid" + echo -n "Did not find mentioned Change-Id on master for a possible backport. Continue (y/N): " + read moveon + fi + fi + + if [ "${moveon}" = 'Y' ] || [ "${moveon}" = 'y' ]; then + return; + else + exit 1 + fi +} + rebase_changes() { @@ -139,6 +205,8 @@ main() { set_hooks_commit_msg; + # rfc.sh calls itself from rebase_changes, which uses rfc.sh as the EDITOR + # thus, getting the commit message to work with in the editor_mode. if [ -e "$1" ]; then editor_mode "$@"; return; @@ -148,6 +216,8 @@ main() rebase_changes; + check_backport; + assert_diverge; bug=$(git show --format='%b' | grep -i '^BUG: ' | awk '{print $2}'); |