From 7610520a4d659ca75e61b94b24c0c47d1999f860 Mon Sep 17 00:00:00 2001 From: Han Zhou Date: Thu, 7 Oct 2021 09:40:01 -0700 Subject: [PATCH] committer-responsibilities.rst: Add pre-push hook. Copied from the same document in OVS repo and changed the branch name to "main". Signed-off-by: Han Zhou Acked-by: Numan siddique --- .../internals/committer-responsibilities.rst | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Documentation/internals/committer-responsibilities.rst b/Documentation/internals/committer-responsibilities.rst index 6e5619243c..1280076ad2 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 main branch. +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/main) + n=0 + while read sha + do + n=$(expr $n + 1) + git log -1 $sha + echo + checkpatch.py -1 $sha + done < /dev/null; then + : + else + exit 1 + fi + ;; + esac + done + + exit 0