summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.mrconfig.in21
l---------lib/hooks/git/dgit/pre-push1
l---------lib/hooks/git/git-remote-gcrypt/pre-push1
l---------lib/hooks/git/mailscripts/pre-push1
l---------lib/hooks/git/org-d20/pre-push1
-rwxr-xr-xlib/hooks/git/pre-push-signed-off-by54
6 files changed, 78 insertions, 1 deletions
diff --git a/.mrconfig.in b/.mrconfig.in
index b3ae276f..e95be53a 100644
--- a/.mrconfig.in
+++ b/.mrconfig.in
@@ -314,7 +314,8 @@ skip = ! workstation
checkout = git clone athena:wiki
skip = ! mine
-# --- ~/src repos with special config
+# --- misc. source repos with special config (e.g. installation of git
+# --- hooks)
[src/dgit]
checkout = git clone salsa:dgit-team/dgit
@@ -322,6 +323,7 @@ post_checkout =
cd dgit
git remote add -f athena athena:dgit
dgit setup-new-tree
+ install_git_hooks dgit
skip = lazy
# [src/ublock-origin]
@@ -339,6 +341,23 @@ post_checkout =
fixups = git config commit.gpgsign true
skip = lazy
+[src/mailscripts]
+checkout = git clone 'athena:mailscripts' 'mailscripts'
+post_checkout =
+ install_git_hooks mailscripts
+ cd 'mailscripts'; dgit fetch buster-backports; dgit fetch sid
+skip = ! workstation
+
+[src/org-d20]
+checkout = git clone 'athena:org-d20' 'org-d20'
+post_checkout = install_git_hooks org-d20
+skip = lazy
+
+[src/git-remote-gcrypt]
+checkout = git clone 'athena:git-remote-gcrypt' 'git-remote-gcrypt'
+post_checkout = install_git_hooks git-remote-gcrypt
+skip = ! workstation
+
# --- radicale collections
[lib/radicale]
diff --git a/lib/hooks/git/dgit/pre-push b/lib/hooks/git/dgit/pre-push
new file mode 120000
index 00000000..b095f34d
--- /dev/null
+++ b/lib/hooks/git/dgit/pre-push
@@ -0,0 +1 @@
+../pre-push-signed-off-by \ No newline at end of file
diff --git a/lib/hooks/git/git-remote-gcrypt/pre-push b/lib/hooks/git/git-remote-gcrypt/pre-push
new file mode 120000
index 00000000..b095f34d
--- /dev/null
+++ b/lib/hooks/git/git-remote-gcrypt/pre-push
@@ -0,0 +1 @@
+../pre-push-signed-off-by \ No newline at end of file
diff --git a/lib/hooks/git/mailscripts/pre-push b/lib/hooks/git/mailscripts/pre-push
new file mode 120000
index 00000000..b095f34d
--- /dev/null
+++ b/lib/hooks/git/mailscripts/pre-push
@@ -0,0 +1 @@
+../pre-push-signed-off-by \ No newline at end of file
diff --git a/lib/hooks/git/org-d20/pre-push b/lib/hooks/git/org-d20/pre-push
new file mode 120000
index 00000000..b095f34d
--- /dev/null
+++ b/lib/hooks/git/org-d20/pre-push
@@ -0,0 +1 @@
+../pre-push-signed-off-by \ No newline at end of file
diff --git a/lib/hooks/git/pre-push-signed-off-by b/lib/hooks/git/pre-push-signed-off-by
new file mode 100755
index 00000000..3c500deb
--- /dev/null
+++ b/lib/hooks/git/pre-push-signed-off-by
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# some of this is from
+# https://lubomir.github.io/en/2016-05-04-signoff-hooks.html
+
+remote="$1"
+url="$2"
+
+z40=0000000000000000000000000000000000000000
+
+while read local_ref local_sha remote_ref remote_sha; do
+ if [ "$local_sha" = $z40 ]; then
+ # Permit deletion of branches
+ :
+ elif echo "$remote_ref" | grep -q "^refs/heads/wip/"; then
+ # wip/ branches may contain commits which are not signed off
+ :
+ else
+ if [ "$remote_sha" = $z40 ]
+ then
+ # New branch, examine all commits
+ range="$local_sha"
+ else
+ # Update to existing branch, examine new commits
+ range="$remote_sha..$local_sha"
+ fi
+
+ # Check for WIP commit
+ commit=$(git rev-list -n 1 --grep '^WIP' "$range")
+ if [ -n "$commit" ]
+ then
+ echo >&2 "Found WIP commit in $local_ref, not pushing"
+ exit 1
+ fi
+
+ # Check for commits without sign-off
+ if [ "$remote_sha" = $z40 ]; then
+ # New branch is pushed, we only want to check commits that are not
+ # on master.
+ range="$(git merge-base master "$local_sha")..$local_sha"
+ fi
+ while read ref; do
+ msg=$(git log -n 1 --format=%B "$ref")
+ if ! grep -q '^Signed-off-by: ' <<<"$msg"; then
+ echo >&2 "Unsigned-off commit $ref"
+ exit 1
+ fi
+ done < <(git rev-list "$range")
+ # The process substitution above is a hack to make sure loop runs in
+ # the same shell and can actually exit the whole script.
+ fi
+done
+
+exit 0