drm_hwcomposer: Add commit message validation to CI
Check the subject prefix starts with "drm_hwcomposer: " and we have
Signed-off-by tags for both author and committer.
Change-Id: Ib26b8e5cbeae2156014f2bbfb8703545bdc1decb
Signed-off-by: Sean Paul <seanpaul@chromium.org>
diff --git a/.gitlab-ci-checkcommit.sh b/.gitlab-ci-checkcommit.sh
index 9023410..fc8963a 100755
--- a/.gitlab-ci-checkcommit.sh
+++ b/.gitlab-ci-checkcommit.sh
@@ -1,9 +1,37 @@
#! /usr/bin/env bash
+echoerr() {
+ printf "ERROR: %s\n" "$*" >&2
+}
+
git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git
-git diff -U0 --no-color FETCH_HEAD...HEAD -- | clang-format-diff-5.0 -p 1 -style=file > format-fixup.patch
-if [ -s format-fixup.patch ]; then
- cat format-fixup.patch
- exit 1
-fi
+git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do
+ subject=$(git show -s --pretty='%s' "$h")
+ if [[ $subject != drm_hwcomposer:* ]]; then
+ echoerr "Invalid subject prefix: $subject"
+ exit 1
+ fi
+
+ 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
+ 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
+ echoerr "Committer SoB tag is missing from commit $h"
+ exit 1
+ fi
+
+ git show "$h" -- | clang-format-diff-5.0 -p 1 -style=file > format-fixup.patch
+ if [ -s format-fixup.patch ]; then
+ cat format-fixup.patch >&2
+ exit 1
+ fi
+done