diff options
author | Sean Paul <seanpaul@chromium.org> | 2019-01-30 09:45:21 -0500 |
---|---|---|
committer | Sean Paul <seanpaul@chromium.org> | 2019-01-30 09:45:21 -0500 |
commit | dafaabd0509a501632d7bc2e5dc5412e52818281 (patch) | |
tree | e0ce993b86056eb71c3dd04f98b232cfca2c356c | |
parent | 734ee1c2e3d0b2c39f111db8efbf253bc17005b8 (diff) | |
download | drm_hwcomposer-dafaabd0509a501632d7bc2e5dc5412e52818281.tar.gz |
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>
-rwxr-xr-x | .gitlab-ci-checkcommit.sh | 29 |
1 files changed, 25 insertions, 4 deletions
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 @@ echoerr() { 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 @@ git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do 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 |