diff options
author | Darshit Shah <darnir@gnu.org> | 2023-05-14 21:38:18 +0200 |
---|---|---|
committer | Darshit Shah <git@darnir.net> | 2023-05-14 21:55:01 +0200 |
commit | 0fea7bc0766d51dd24ab97ca4b34a2be544a0a03 (patch) | |
tree | 149cb80ad4ccff9262f3a4da9451d5b11601bd0c | |
parent | 6ca59f4d609cf8f1ae91a47dedde1b8f3a0d46b9 (diff) | |
download | wget-0fea7bc0766d51dd24ab97ca4b34a2be544a0a03.tar.gz |
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
-rw-r--r-- | .gitlab-ci.yml | 11 | ||||
-rwxr-xr-x | contrib/commit-check | 48 |
2 files changed, 59 insertions, 0 deletions
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 <https://www.gnu.org/licenses/>. + +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 |