hooks: pre-push: Verify that co-authors have a SoB line
diff mbox series

Message ID 20241007191403.26881-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit fc761ffe499bed5ac5a9d2313b87be85f4d41a71
Headers show
Series
  • hooks: pre-push: Verify that co-authors have a SoB line
Related show

Commit Message

Laurent Pinchart Oct. 7, 2024, 7:14 p.m. UTC
The Co-developed-by tag must be followed by a corresponding SoB line.
Enforce this rule in the git pre-push hook.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/hooks/pre-push | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)


base-commit: a7d573df53ff2fe2edaaf4c11a269f12b1a9e305

Comments

Kieran Bingham Oct. 7, 2024, 11:21 p.m. UTC | #1
Quoting Laurent Pinchart (2024-10-07 20:14:03)
> The Co-developed-by tag must be followed by a corresponding SoB line.
> Enforce this rule in the git pre-push hook.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  utils/hooks/pre-push | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push
> index 9918b2861705..68dcbd0cccc8 100755
> --- a/utils/hooks/pre-push
> +++ b/utils/hooks/pre-push
> @@ -68,7 +68,7 @@ do
>                 fi
>  
>                 # 2. The commit message shall have Signed-off-by lines
> -               # corresponding the committer and the author.
> +               # corresponding the committer, author, and all co-developers.
>                 committer=$(echo "$msg" | grep '^committer ' | head -1 | \
>                                 cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)
>                 if ! echo -E "$msg" | grep -F -q "Signed-off-by: ${committer}"
> @@ -85,6 +85,15 @@ do
>                         errors=$((errors+1))
>                 fi
>  
> +               while read -r codev
> +               do
> +                       if ! echo -E "$msg" | grep -F -q "Signed-off-by: ${codev}"
> +                       then
> +                               echo >&2 "Missing co-developer '${codev}' Signed-off-by in commit $commit"
> +                               errors=$((errors+1))
> +                       fi
> +               done < <(echo "$msg" | grep '^Co-developed-by: ' | cut -d ' ' -f 2-)
> +

$ echo test-main 5982c728cd0b2f247058b5aa57994c273fdd8d04 refs/heads/integration/pre-push-test a7d573df53ff2fe2edaaf4c11a269f12b1a9e305 | ./utils/hooks/pre-push maintest
...
Missing co-developer 'Harvey Yang <chenghaoyang@chromium.org>' Signed-off-by in commit 2baad75b4420b4533c998b63d4588fcef1f3b356
Missing co-developer 'Yunke Cao <yunkec@chromium.org>' Signed-off-by in commit 2baad75b4420b4533c998b63d4588fcef1f3b356
Missing co-developer 'Tomasz Figa <tfiga@chromium.org>' Signed-off-by in commit 2baad75b4420b4533c998b63d4588fcef1f3b356
No Reviewed-by or Acked-by in commit 2baad75b4420b4533c998b63d4588fcef1f3b356
...

Looks good to me 

Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>                 # 3. A Reviewed-by or Acked-by is required.
>                 if ! echo -E "$msg" | grep -q '^\(Reviewed\|Acked\)-by: '
>                 then
> 
> base-commit: a7d573df53ff2fe2edaaf4c11a269f12b1a9e305
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push
index 9918b2861705..68dcbd0cccc8 100755
--- a/utils/hooks/pre-push
+++ b/utils/hooks/pre-push
@@ -68,7 +68,7 @@  do
 		fi
 
 		# 2. The commit message shall have Signed-off-by lines
-		# corresponding the committer and the author.
+		# corresponding the committer, author, and all co-developers.
 		committer=$(echo "$msg" | grep '^committer ' | head -1 | \
 				cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)
 		if ! echo -E "$msg" | grep -F -q "Signed-off-by: ${committer}"
@@ -85,6 +85,15 @@  do
 			errors=$((errors+1))
 		fi
 
+		while read -r codev
+		do
+			if ! echo -E "$msg" | grep -F -q "Signed-off-by: ${codev}"
+			then
+				echo >&2 "Missing co-developer '${codev}' Signed-off-by in commit $commit"
+				errors=$((errors+1))
+			fi
+		done < <(echo "$msg" | grep '^Co-developed-by: ' | cut -d ' ' -f 2-)
+
 		# 3. A Reviewed-by or Acked-by is required.
 		if ! echo -E "$msg" | grep -q '^\(Reviewed\|Acked\)-by: '
 		then