diff mbox series

[ovs-dev] Documentation: Document a useful pre-push hook for committers.

Message ID 20190925200231.20712-1-blp@ovn.org
State Accepted
Commit eedd4fd7481e6f2bc14c4e9d0afa7ae091dc1398
Headers show
Series [ovs-dev] Documentation: Document a useful pre-push hook for committers. | expand

Commit Message

Ben Pfaff Sept. 25, 2019, 8:02 p.m. UTC
Someone else wrote this script originally, I think, but I've extended
it quite a bit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 .../internals/committer-responsibilities.rst  | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)

Comments

Simon Horman Oct. 1, 2019, 11:52 a.m. UTC | #1
On Wed, Sep 25, 2019 at 01:02:31PM -0700, Ben Pfaff wrote:
> Someone else wrote this script originally, I think, but I've extended
> it quite a bit.
> 
> Signed-off-by: Ben Pfaff <blp@ovn.org>

Reviewed-by: Simon Horman <simon.horman@netronome.com>
Ben Pfaff Oct. 1, 2019, 5:27 p.m. UTC | #2
On Tue, Oct 01, 2019 at 01:52:54PM +0200, Simon Horman wrote:
> On Wed, Sep 25, 2019 at 01:02:31PM -0700, Ben Pfaff wrote:
> > Someone else wrote this script originally, I think, but I've extended
> > it quite a bit.
> > 
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> 
> Reviewed-by: Simon Horman <simon.horman@netronome.com>

Thanks!  I applied this to master.
diff mbox series

Patch

diff --git a/Documentation/internals/committer-responsibilities.rst b/Documentation/internals/committer-responsibilities.rst
index 4d10c3980875..c35fd708913b 100644
--- a/Documentation/internals/committer-responsibilities.rst
+++ b/Documentation/internals/committer-responsibilities.rst
@@ -94,3 +94,53 @@  Use Reported-by: and Tested-by: tags in commit messages to indicate the
 source of a bug report.
 
 Keep the ``AUTHORS.rst`` file up to date.
+
+Pre-Push Hook
+-------------
+
+The following script can be helpful because it provides an extra
+chance to check for mistakes while pushing to the master branch of OVS
+or OVN.  If you would like to use it, install it as ``hooks/pre-push``
+in your ``.git`` directory and make sure to mark it as executable with
+``chmod +x``.  For maximum utility, make sure ``checkpatch.py`` is in
+``$PATH``:
+
+.. code-block:: bash
+
+  #! /bin/bash
+
+  remote=$1
+
+  case $remote in
+      ovs|ovn|origin) ;;
+      *) exit 0 ;;
+  esac
+
+  while read local_ref local_sha1 remote_ref remote_sha1; do
+      case $remote_ref in
+          refs/heads/master)
+              n=0
+              while read sha
+              do
+                  n=$(expr $n + 1)
+                  git log -1 $sha
+                  echo
+                  checkpatch.py -1 $sha
+              done <<EOF
+  $(git --no-pager log --pretty=%H $local_sha1...$remote_sha1)
+  EOF
+
+              b=${remote_ref#refs/heads/}
+              echo "You're about to push $n commits to protected branch $b on $remote."
+
+              read -p "Do you want to proceed? [y|n] " reply < /dev/tty
+              if echo $reply | grep -E '^[Yy]$' > /dev/null; then
+                  :
+              else
+                  exit 1
+              fi
+              ;;
+      esac
+  done
+
+  exit 0