diff options
| author | Harshavardhana <harsha@harshavardhana.net> | 2014-06-25 21:22:49 -0700 | 
|---|---|---|
| committer | Harshavardhana <harsha@harshavardhana.net> | 2014-09-18 12:55:26 -0700 | 
| commit | c788a7784d8526b72714d60bac6e1e09ae985a84 (patch) | |
| tree | 692a2fa7b0aeabf658c81f427599cfc65c96be4e /rfc.sh | |
| parent | 1e1b709a4b438dfa768fd4c645e081ede06e7e14 (diff) | |
extras/checkpatch.pl: linux kernel style patch verification
This is to bring in adherence to coding policy, prior to patch
submission for review.
 - no tabs
 - no whitespace
 - indentation (linux style) etc.
This is in the interest at large for the GlusterFS codebase
to be more cleaner and readable.
./rfc.sh - now supports running this for all patches diverged
from "origin/master" revision.
NOTE: One should take this as a handle for good guidelines and
never use it as a tool for correctness, use common-sense in all
the cases ;-)
Change-Id: Ib9a5ed207cde152cb92b8d38cec83e8ce9ef7f28
BUG: 1120646
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/8181
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anders Blomdell <anders.blomdell@control.lth.se>
Diffstat (limited to 'rfc.sh')
| -rwxr-xr-x | rfc.sh | 47 | 
1 files changed, 43 insertions, 4 deletions
@@ -1,9 +1,11 @@  #!/bin/sh -e - +# Since we run with '#!/bin/sh -e' +#   '$? != 0' will force an exit, +# i.e. where we are interested in the result of a command, +# we have to run the command in an if-statement.  branch="master"; -  set_hooks_commit_msg()  {      f=".git/hooks/commit-msg"; @@ -34,8 +36,6 @@ is_num()  rebase_changes()  { -    git fetch origin; -      GIT_EDITOR=$0 git rebase -i origin/$branch;  } @@ -82,6 +82,43 @@ assert_diverge()      git diff origin/$branch..HEAD | grep -q .;  } +check_patches_for_coding_style() +{ +    git fetch origin; + +    check_patch_script=./extras/checkpatch.pl +    if [ ! -e ./extras/checkpatch.pl ] ; then +        echo "checkpatch is not executable .. abort" +        exit 1 +    fi + +    ## Set this to known value once Jenkins URL changes +    export JENKINS_URL="review.gluster.org" + +    echo "Running coding guidelines check ..." +    head=$(git rev-parse --abbrev-ref HEAD) +    # Kludge: "1>&2 && echo $? || echo $?" is to get around +    #         "-e" from script invocation +    RES=$(git format-patch --stdout origin/${branch}..${head} \ +          | ${check_patch_script} --terse - 1>&2 && echo $? || echo $?) +    if [ "$RES" -eq 1 ] ; then +        echo "Errors caught, get details by:" +        echo "  git format-patch --stdout  origin/${branch}..${head} \\" +        echo "  | ./extras/checkpatch.pl --jenkins-url ${JENKINS_URL} -" +        echo "and correct errors" +        exit 1 +    elif [ "$RES" -eq 2 ] ; then +        echo "Warnings caught, get details by:" +        echo "  git format-patch --stdout  origin/${branch}..${head} \\" +        echo "  | ./extras/checkpatch.pl --jenkins-url ${JENKINS_URL} -" +        echo -n "Do you want to continue anyway [no/yes]: " +        read yesno +        if [ "${yesno}" != "yes" ] ; then +            echo "Aborting..." +            exit 1 +        fi +    fi +}  main()  { @@ -92,6 +129,8 @@ main()          return;      fi +    check_patches_for_coding_style; +      rebase_changes;      assert_diverge;  | 
