aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.builds/alpine-edge.yml3
-rw-r--r--CONTRIBUTING.md7
-rw-r--r--Makefile12
-rwxr-xr-xcontrib/check-patches39
-rwxr-xr-xcontrib/sendemail-validate11
5 files changed, 70 insertions, 2 deletions
diff --git a/.builds/alpine-edge.yml b/.builds/alpine-edge.yml
index 074a5e11..e77062a4 100644
--- a/.builds/alpine-edge.yml
+++ b/.builds/alpine-edge.yml
@@ -11,6 +11,9 @@ environment:
DESTDIR: ./out
GOFLAGS: "-tags=notmuch"
tasks:
+ - check-patches: |
+ cd aerc
+ make check-patches
- lint: |
cd aerc
make lint
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 44a567be..dc8f17cb 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -65,8 +65,11 @@ example:
Before sending the patch, you should configure your local clone with sane
defaults:
- $ git config format.subjectPrefix "PATCH aerc"
- $ git config sendemail.to "~rjarry/aerc-devel@lists.sr.ht"
+ $ make gitconfig
+ git config format.subjectPrefix "PATCH aerc"
+ git config sendemail.to "~rjarry/aerc-devel@lists.sr.ht"
+ git config sendemail.validate true
+ ln -sf ../../contrib/sendemail-validate .git/hooks/sendemail-validate
And send the patch to the mailing list ([step by step
instructions][git-send-email-tutorial]):
diff --git a/Makefile b/Makefile
index 4e37b5f2..1fccacc9 100644
--- a/Makefile
+++ b/Makefile
@@ -185,4 +185,16 @@ uninstall:
$(RM) $(DESTDIR)$(PREFIX)/share/applications/aerc.desktop
$(RMDIR_IF_EMPTY) $(DESTDIR)$(PREFIX)/share/applications
+.PHONY: gitconfig
+gitconfig:
+ git config format.subjectPrefix "PATCH aerc"
+ git config sendemail.to "~rjarry/aerc-devel@lists.sr.ht"
+ git config sendemail.validate true
+ @mkdir -p .git/hooks
+ ln -sf ../../contrib/sendemail-validate .git/hooks/sendemail-validate
+
+.PHONY: check-patches
+check-patches:
+ @contrib/check-patches origin/master..
+
.PHONY: all doc clean install uninstall debug
diff --git a/contrib/check-patches b/contrib/check-patches
new file mode 100755
index 00000000..738b1816
--- /dev/null
+++ b/contrib/check-patches
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+set -e
+
+revision_range="${1?revision range}"
+
+total=0
+valid=0
+
+for rev in $(git rev-list --reverse "$revision_range"); do
+ total=$((total + 1))
+ title=$(git log --format='%s' -1 "$rev")
+
+ author=$(git log --format='%aN <%aE>' -1 "$rev")
+ git log --format="%(trailers:key=Signed-off-by,only,valueonly)" -1 "$rev" |
+ grep -qFx "$author" || {
+ echo "error: '$title' 'Signed-off-by: $author' trailer is missing" >&2
+ continue
+ }
+
+ body=$(git log --format='%b' -1 "$rev")
+ body=${body%$(git log --format='%(trailers)' -1 "$rev")}
+ if [ "$(echo "$body" | wc -w)" -lt 3 ]; then
+ echo "error: '$title' body has less than three words, please elaborate" >&2
+ continue
+ fi
+
+ echo "ok: '$title'"
+ valid=$((valid + 1))
+done
+
+if [ "$total" -eq 0 ]; then
+ exit 0
+fi
+
+echo "$valid/$total valid patches"
+if [ "$valid" -ne "$total" ]; then
+ exit 1
+fi
diff --git a/contrib/sendemail-validate b/contrib/sendemail-validate
new file mode 100755
index 00000000..1d18e65c
--- /dev/null
+++ b/contrib/sendemail-validate
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+email="${1?email file}"
+tmp=$(mktemp -d)
+trap "rm -rf -- $tmp" EXIT
+git clone -q --depth=1 "https://git.sr.ht/~rjarry/aerc" "$tmp"
+export GIT_DIR="$tmp/.git"
+git -C "$tmp" am -q3 "$email"
+make -sC "$tmp" check-patches all lint tests