]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Check for Signed-off-by: in CI
authorTim Rühsen <tim.ruehsen@gmx.de>
Thu, 10 Jan 2019 13:53:32 +0000 (14:53 +0100)
committerTim Rühsen <tim.ruehsen@gmx.de>
Sun, 20 Jan 2019 12:20:41 +0000 (13:20 +0100)
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
.gitlab-ci.yml
devel/check_if_signed [new file with mode: 0755]

index 6a7652ddeb6379b9d945c91a585af79813e260c9..cc6746103437bff1a11102e125598ac601ba1fd2 100644 (file)
@@ -31,6 +31,7 @@ variables:
   DEBIAN_X86_CROSS_BUILD: buildenv-debian-x86-cross
   FEDORA28_BUILD: buildenv-f28
   FEDORA_BUILD: buildenv-f29
+  ALPINE_BASE_BUILD: buildenv-alpine-base
   CPPCHECK_OPTIONS: "--enable=warning --enable=style --enable=performance --enable=portability --std=c99 --suppressions-list=devel/cppcheck.suppressions --template='{id}:{file}:{line},{severity},{message}'"
   GET_SOURCES_ATTEMPTS: "3"
 
@@ -38,6 +39,23 @@ variables:
 # Stage 1, documentation, and advanced checks
 ##################################################
 
+commit-check:
+  stage: stage1-testing
+  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$ALPINE_BASE_BUILD
+  before_script:
+    - /bin/true
+  after_script:
+    - /bin/true
+  cache:
+    # do not load cache files
+    key: none
+    policy: pull
+  script:
+    # we want $ALPINE_BASE_BUILD without git, so add it here
+    - apk add git
+    - devel/check_if_signed
+  retry: 0
+
 doc-dist.Fedora:
   stage: stage1-testing
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
diff --git a/devel/check_if_signed b/devel/check_if_signed
new file mode 100755 (executable)
index 0000000..a053bbc
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env sh
+
+if test -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"; then
+  CI_MERGE_REQUEST_TARGET_BRANCH_NAME="master"
+fi
+
+echo "target=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
+echo "source=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"
+
+# create list of commits of the current branch
+commits=$(git rev-list --no-merges $CI_MERGE_REQUEST_TARGET_BRANCH_NAME..$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME)
+
+# check if author's email matches email in 'Signed-off-by'
+for hash in $commits; do
+  author=$(git log --format='%ae' ${hash}^\!)
+  signed=$(git log --format='%b' ${hash}^\! | grep -i "Signed-off-by:")
+  if test $? -ne 0; then
+    echo "Missing Signed-off-by"
+    exit 1
+  fi
+  if ! echo $signed | grep -q "Signed-off-by:.*<${author}>"; then
+    echo "Author '${author}' doesn't match"
+    exit 1
+  fi
+done