diff options
author | Shyam <srangana@redhat.com> | 2017-04-10 11:36:17 -0400 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-04-19 08:18:17 -0400 |
commit | 2aeca0ef02733ebd9b7979e4c27585f3ebff53d7 (patch) | |
tree | 83b0c077aa744bdf9cf27083f40396702f2c3f2d | |
parent | b350bcd6a3db2e92d1baa47a5ec02efd09f76f16 (diff) |
scripts: Update rfc.sh to prompt for a github issue on RFE commits
If a commit does not contain a bug check with the committer if
this is an RFE (or such) and prompt to amend the commit with a
github issue that relates to the change.
Also, give some specifics on what string to add to refer to an
issue.
This change is meant to encourage committers to add github issues
and hence will not enforce the same, IOW the check can be ignored
and code can still be submitted. Reviewers would hence be
responsible to check for the same.
Change-Id: Id382247a787a96d55be6be554332a1b7ccde6bcd
BUG: 1428036
Signed-off-by: Shyam <srangana@redhat.com>
Reviewed-on: https://review.gluster.org/17032
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rwxr-xr-x | rfc.sh | 82 |
1 files changed, 82 insertions, 0 deletions
@@ -200,6 +200,80 @@ check_patches_for_coding_style() fi } +github_issue_message() +{ + echo "" + echo "=== Missing a github issue reference in a potential enhancement! ===" + echo "" + echo "Gluster code submissions that are enhancements (IOW, not functional" + echo "bug fixes, but improvements of any nature to the code) are tracked" + echo "using github issues. A check on the commit message, reveals that" + echo "there is no bug associated with this change, hence it could be a" + echo "potential code improvement or feature enhancement" + echo "" + echo "If this is an enhancement, request a github issue be filed at [1]" + echo "and referenced in the commit message as," + echo "\"Fixes gluster/glusterfs#n\" OR \"Updates gluster/glusterfs#n\"," + echo "where n is the issue number" + echo "" + echo "You can reference multiple issues that this commit addresses as," + echo "\"fixes gluster/glusterfs#n, updates gluster/glusterfs#m\", and so on" + echo "" + echo "[1] https://github.com/gluster/glusterfs/issues/new" + echo "" + echo "You may abort the submission choosing 'N' below and use" + echo "'git commit --amend' to add the issue reference before posting" + echo "to gerrit. If this is a bug fix, choose 'Y' to continue." + echo "" +} + +check_for_github_issue() +{ + # NOTE: Since we run '#!/bin/sh -e', the check is in an if, + # as grep count maybe 0 + # + # Regex elaborated: + # grep -w -> --word-regexp (from the man page) + # Select only those lines containing matches that form whole words. + # The test is that the matching substring must either be at the + # beginning of the line, or preceded by a non-word constituent + # character. Similarly, it must be either at the end of the line or + # followed by a non-word constituent character. Word-constituent + # characters are letters, digits, and the underscore. + # IOW, the above helps us find the pattern with leading or training spaces + # or non word consituents like , or ; + # + # grep -c -> gives us a count of matches, which is all we need here + # + # [fF][iI][xX][eE][sS]|[uU][pP][dD][aA][tT][eE][sS]) + # Finds 'fixes' OR 'updates' in any case combination + # + # (:)? + # Followed by an optional : (colon) + # + # [[:space:]]+ + # followed by 1 or more spaces + # + # (gluster\/glusterfs)? + # Followed by 0 or more gluster/glusterfs + # + # # + # Followed by # + # + # [[:digit:]]+ + # Followed by 1 or more digits + if [ 0 = "$(git log --format=%B -n 1 | grep -cow -E "([fF][iI][xX][eE][sS]|[uU][pP][dD][aA][tT][eE][sS])(:)?[[:space:]]+(gluster\/glusterfs)?#[[:digit:]]+")" ]; then + moveon='N' + github_issue_message; + echo -n "Missing github issue reference in a potential RFE. Continue (y/N): " + read moveon + if [ "${moveon}" = 'Y' ] || [ "${moveon}" = 'y' ]; then + return; + else + exit 1 + fi + fi +} main() { @@ -222,6 +296,14 @@ main() bug=$(git show --format='%b' | grep -i '^BUG: ' | awk '{print $2}'); + # If this is a commit against master and does not have a bug ID + # it could be a feature or an RFE, check if there is a github + # issue reference, and if not suggest commit message amendment + if [ -z "$bug" ] && [ $branch = "master" ]; then + check_for_github_issue; + fi + + if [ "$DRY_RUN" = 1 ]; then drier='echo -e Please use the following command to send your commits to review:\n\n' else |