utils: hooks: pre-push: Catch commits without author's SoB

The pre-push git hook script catches commits without a SoB line
corresponding to the committer, but doesn't perform the same check on
the author. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2022-03-26 19:41:55 +02:00
parent 7349031294
commit 4efca856c0

View file

@ -67,8 +67,8 @@ do
errors=$((errors+1)) errors=$((errors+1))
fi fi
# 2. The commit message shall have a Signed-off-by line # 2. The commit message shall have Signed-off-by lines
# corresponding the committer. # corresponding the committer and the author.
committer=$(echo "$msg" | grep '^committer ' | head -1 | \ committer=$(echo "$msg" | grep '^committer ' | head -1 | \
cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev) cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)
if ! echo "$msg" | grep -F -q "Signed-off-by: ${committer}" if ! echo "$msg" | grep -F -q "Signed-off-by: ${committer}"
@ -77,6 +77,14 @@ do
errors=$((errors+1)) errors=$((errors+1))
fi fi
author=$(echo "$msg" | grep '^author ' | head -1 | \
cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)
if ! echo "$msg" | grep -F -q "Signed-off-by: ${author}"
then
echo >&2 "Missing author Signed-off-by in commit $commit"
errors=$((errors+1))
fi
# 3. A Reviewed-by or Acked-by is required. # 3. A Reviewed-by or Acked-by is required.
if ! echo "$msg" | grep -q '^\(Reviewed\|Acked\)-by: ' if ! echo "$msg" | grep -q '^\(Reviewed\|Acked\)-by: '
then then