drm_hwcomposer: Fix check commit script to ignore case and extra spaces
Job 93709 [1] failed with missing committer sign-off. Ayan has their
committer string set to "Ayan kumar halder <ayan.halder@arm.com>", and
the Signed-off-by line on the commit was
"Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>". So grep did
what we asked it to do and did not find the SoB since the case was
incorrect.
This patch changes to case-insensitive search and while we're at it,
trims excess whitespace from both the commit body and the
committer/author name.
Finally, I've improved the error message so it's hopefully more clear
why things fail in the future.
[1]- https://gitlab.freedesktop.org/ayan.halder/drm-hwcomposer/-/jobs/93709
Signed-off-by: Sean Paul <seanpaul@chromium.org>
diff --git a/.gitlab-ci-checkcommit.sh b/.gitlab-ci-checkcommit.sh
index fc8963a..d76baf7 100755
--- a/.gitlab-ci-checkcommit.sh
+++ b/.gitlab-ci-checkcommit.sh
@@ -4,6 +4,29 @@
printf "ERROR: %s\n" "$*" >&2
}
+findtag() {
+ local commit_body tag person
+ commit_body=$1
+ tag=$2
+ person=$3
+
+ # trim duplicate spaces from commit body and person
+ match="$tag: $(echo $person | tr -s ' ')"
+
+ if [ -z "$(echo "$commit_body" | tr -s ' ' | grep -i "$match")" ]; then
+ echoerr "Tag is missing from commit body"
+ echoerr ""
+ echoerr "Looking for '"$match"' in: "
+ echoerr "-----------------------------------------------------"
+ echoerr "$commit_body"
+ echoerr "-----------------------------------------------------"
+ echoerr ""
+ return 0
+ fi
+
+ return 1
+}
+
git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git
git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do
@@ -16,15 +39,13 @@
commit_body=$(git show -s --pretty=%b "$h")
author=$(git show -s --format='%an <%ae>')
- sob=$(echo "$commit_body" | grep "Signed-off-by: $author")
- if [ -z "$sob" ] ; then
+ if findtag "$commit_body" "Signed-off-by" "$author"; then
echoerr "Author SoB tag is missing from commit $h"
exit 1
fi
committer=$(git show -s --format='%cn <%ce>')
- sob=$(echo "$commit_body" | grep "Signed-off-by: $committer")
- if [ -z "$sob" ] ; then
+ if findtag "$commit_body" "Signed-off-by" "$committer"; then
echoerr "Committer SoB tag is missing from commit $h"
exit 1
fi