From 0fea7bc0766d51dd24ab97ca4b34a2be544a0a03 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Sun, 14 May 2023 21:38:18 +0200 Subject: [PATCH] Automatically verify if commit author has assigned copyrights in the past * contrib/commit-check: Add new script * .gitlab-ci.yml: Add new test in the CI pipeline --- .gitlab-ci.yml | 11 ++++++++++ contrib/commit-check | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 contrib/commit-check diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd3ae8fe..76c7c433 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,6 +41,17 @@ variables: CONFIGURE_BASE_FLAGS: --enable-assert --cache-file cache/config.cache CFLAGS_DEFAULT: -O0 -g -ggdb3 +CommitCheck: + stage: test-from-git + image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_TESTING_BUILD + script: + - ./contrib/commit-check + allow_failure: true + cache: + paths: + policy: push + + # Create the tarball in a separate build directory (VPATH). Build-Tarball: stage: test-from-git diff --git a/contrib/commit-check b/contrib/commit-check new file mode 100755 index 00000000..8e960899 --- /dev/null +++ b/contrib/commit-check @@ -0,0 +1,48 @@ +#!/usr/bin/env sh + +# Copyright (c) 2018-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e +set -u + +AUTHOR=$(git log -n1 --format='%aN') +EMAIL=$(git log -n1 --format='%aE') +DOMAIN=$(echo "$EMAIL" | cut -d'@' -f2) +EMAIL_PARSE=$(echo "$EMAIL" | sed 's/@/ \\[at\\] /g') + +retval=0 + +echo "The last commit is made by $AUTHOR: $EMAIL_PARSE" + +if git cat-file -p HEAD | grep "^Copyright-paperwork-exempt: Yes"; then + echo "This work is copyright paperwork exempt." +elif ! grep -E -q "^\\[ASSGN\\] .* \\*($EMAIL_PARSE|$DOMAIN)\\*$" AUTHORS; then + if grep -E -q "^\\[ *\\] .* \\*($EMAIL_PARSE|$DOMAIN)\\*$" AUTHORS; then + echo "The author is known, but did not yet complete the FSF Copyright Assignment." + else + echo "The author was not found in the AUTHORS file." + echo "Has the author completed the FSF Copyright Assignment?" + fi + echo + echo "If the commit is minor, please add this to the commit message:" + echo "Copyright-paperwork-exempt: Yes" + retval=1 +else + echo "The author or company was found in the AUTHORS file." + echo "This work may be merged into master" +fi + +exit $retval