aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-09-29 11:26:44 +0200
committerMichał Górny <mgorny@gentoo.org>2019-04-09 13:05:55 +0200
commitd7053a7a08e88ee3bdc2d72f6862d818f13db1b0 (patch)
tree0fe89d7531fe46cb571b5309f3a58c0a7d811dbd
parentHook to test GCO sign-off (diff)
downloadgithooks-d7053a7a08e88ee3bdc2d72f6862d818f13db1b0.tar.gz
githooks-d7053a7a08e88ee3bdc2d72f6862d818f13db1b0.tar.bz2
githooks-d7053a7a08e88ee3bdc2d72f6862d818f13db1b0.zip
update-06-copyright: Prohibit committing licenses with DCO-1.1
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rwxr-xr-xlocal/tests/update-06-copyright.sh24
-rwxr-xr-xlocal/update-06-copyright14
2 files changed, 38 insertions, 0 deletions
diff --git a/local/tests/update-06-copyright.sh b/local/tests/update-06-copyright.sh
index 7710c98..1ffc1d3 100755
--- a/local/tests/update-06-copyright.sh
+++ b/local/tests/update-06-copyright.sh
@@ -42,6 +42,7 @@ FAIL_SYNTAX="*: malformed sign-off (should be: real name <email>)!
*"
FAIL_REALNAME="*: name of sign-off does not match realname in LDAP!
*"
+FAIL_LICENSE="*: DCO-1.1 sign-off used on license directory!"
# Non-developer commit tests (for repos that allow those)
export GL_USER=nondev@example.com
@@ -98,6 +99,29 @@ test_success
eoutdent
+einfo "License directory tests"
+eindent
+
+tbegin "GCO sign-off on licenses directory"
+mkdir -p licenses || die
+echo 'Unmodifiable license' > licenses/mylicense || die
+git add licenses/mylicense
+git commit -m "A commit with license
+
+Signed-off-by: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}>" -q
+test_success
+
+tbegin "Linux DCO sign-off on licenses directory"
+mkdir -p licenses || die
+echo 'Unmodifiable license' > licenses/mylicense || die
+git add licenses/mylicense
+git commit -m "A commit with license
+
+Signed-off-by: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}> (DCO-1.1)" -q
+test_failure "${FAIL_LICENSE}"
+
+eoutdent
+
einfo "Syntax check tests"
eindent
diff --git a/local/update-06-copyright b/local/update-06-copyright
index e08ff4e..ffc3d96 100755
--- a/local/update-06-copyright
+++ b/local/update-06-copyright
@@ -80,6 +80,17 @@ while read -r commithash; do
break
fi
+ # verify that DCO-1.1 is not used on licenses directory
+ # (suggested by leio)
+ if [[ ${line} == *DCO[-\ ]1* ]]; then
+ while read -r -d $'\0' filename; do
+ if [[ ${filename} == licenses/* ]]; then
+ signoff=dcolicense
+ break 2
+ fi
+ done < <(git diff -z --name-only "${commithash}^" "${commithash}")
+ fi
+
# if we already found the correct one, just verify syntax
# of the rest
[[ ${signoff} == ok ]] && continue
@@ -121,6 +132,9 @@ while read -r commithash; do
echo "${commithash}: malformed sign-off (should be: real name <email>)!"
echo " ${line}"
ret=1;;
+ dcolicense)
+ echo "${commithash}: DCO-1.1 sign-off used on license directory!"
+ ret=1;;
diffmail)
echo "${commithash}: no sign-off matching committer's e-mail address found!"
echo " expected: ${committer}"