OSDN Git Service

drm_hwcomposer: Add commit message validation to CI
authorSean Paul <seanpaul@chromium.org>
Tue, 4 Sep 2018 19:32:26 +0000 (15:32 -0400)
committerSean Paul <seanpaul@chromium.org>
Wed, 5 Sep 2018 12:49:58 +0000 (12:49 +0000)
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>
.gitlab-ci-checkcommit.sh
.gitlab-ci.yml

index 9023410..fc8963a 100755 (executable)
@@ -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
index d0175f0..c97f4ff 100644 (file)
@@ -12,5 +12,4 @@ checkstyle:
   script: "./.gitlab-ci-checkcommit.sh"
   artifacts:
     when: on_failure
-    paths:
-      - format-fixup.patch
+    untracked: true