diff mbox

dim: add checks for author and committer sign-off-by

Message ID 1501064831-23404-1-git-send-email-benjamin.gaignard@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Gaignard July 26, 2017, 10:27 a.m. UTC
Rework checkpatch_commit_push logic to check for author and
committer sign-off-by.
Also add a check for "Link" tag added by dim apply-branch.

Remove the committer != author check because obviously some
authors commit their patches themselves. This test was
never done anyway because the first check of the function
directly return if true.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 dim | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Comments

Daniel Vetter July 26, 2017, 10:40 a.m. UTC | #1
On Wed, Jul 26, 2017 at 12:27 PM, Benjamin Gaignard
<benjamin.gaignard@linaro.org> wrote:
> Rework checkpatch_commit_push logic to check for author and
> committer sign-off-by.
> Also add a check for "Link" tag added by dim apply-branch.
>
> Remove the committer != author check because obviously some
> authors commit their patches themselves. This test was
> never done anyway because the first check of the function
> directly return if true.

These check something else: They make sure that you never push
something without either a review/ack or a 2nd sob (which is checked
through commiter != author). Please don't remove/change these checks,
they're still needed, since they check something else.
-Daniel

> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> ---
>  dim | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/dim b/dim
> index 786fe6b..103334c 100755
> --- a/dim
> +++ b/dim
> @@ -661,18 +661,28 @@ function checkpatch_commit_push
>         local sha1
>
>         sha1=$1
> +       author=$(git show -s $sha1 --format="format:%ae")
> +       committer=$(git show -s $sha1 --format="format:%ce")
>
>         # check for a-b/r-b tag
> -       if git show -s $sha1 | grep -qi '\(reviewed\|acked\)\S*-by:'  ; then
> -               return
> +       if ! git show -s $sha1 | grep -qi '\(reviewed\|acked\)\S*-by:'  ; then
> +               warn_or_fail "$sha1 is lacking mandatory review"
>         fi
>
> -       # check for committer != author
> -       if [[ $(git show -s $sha1 --format="format:%ce") != $(git show -s $sha1 --format="format:%ae") ]]; then
> -               return
> +       # check for author sign-off
> +       if ! git show -s $sha1 | grep -qi "S.*-by:.*$author"  ; then
> +               warn_or_fail "$sha1 is lacking author of sign-off"
>         fi
>
> -       warn_or_fail "$sha1 is lacking mandatory review"
> +       # check for committer sign-off
> +       if ! git show -s $sha1 | grep -qi "S.*-by:.*$committer"  ; then
> +               warn_or_fail "$sha1 is lacking committer of sign-off"
> +       fi
> +
> +       # check for Link tag
> +       if ! git show -s $sha1 | grep -qi 'Link:'  ; then
> +               warn_or_fail "$sha1 is lacking of link tag"
> +       fi
>  }
>
>  # push branch $1, rebuild drm-tip. the rest of the arguments are passed to git
> --
> 1.9.1
>
diff mbox

Patch

diff --git a/dim b/dim
index 786fe6b..103334c 100755
--- a/dim
+++ b/dim
@@ -661,18 +661,28 @@  function checkpatch_commit_push
 	local sha1
 
 	sha1=$1
+	author=$(git show -s $sha1 --format="format:%ae")
+	committer=$(git show -s $sha1 --format="format:%ce")
 
 	# check for a-b/r-b tag
-	if git show -s $sha1 | grep -qi '\(reviewed\|acked\)\S*-by:'  ; then
-		return
+	if ! git show -s $sha1 | grep -qi '\(reviewed\|acked\)\S*-by:'  ; then
+		warn_or_fail "$sha1 is lacking mandatory review"
 	fi
 
-	# check for committer != author
-	if [[ $(git show -s $sha1 --format="format:%ce") != $(git show -s $sha1 --format="format:%ae") ]]; then
-		return
+	# check for author sign-off
+	if ! git show -s $sha1 | grep -qi "S.*-by:.*$author"  ; then
+		warn_or_fail "$sha1 is lacking author of sign-off"
 	fi
 
-	warn_or_fail "$sha1 is lacking mandatory review"
+	# check for committer sign-off
+	if ! git show -s $sha1 | grep -qi "S.*-by:.*$committer"  ; then
+		warn_or_fail "$sha1 is lacking committer of sign-off"
+	fi
+
+	# check for Link tag
+	if ! git show -s $sha1 | grep -qi 'Link:'  ; then
+		warn_or_fail "$sha1 is lacking of link tag"
+	fi
 }
 
 # push branch $1, rebuild drm-tip. the rest of the arguments are passed to git