diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-14 15:20:35 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-14 22:17:19 +0100 |
commit | 86eed28e65aed43a4b017f758405ca85fd74bf21 (patch) | |
tree | 7619ffc4042834365a53ba748af27932be1dd325 /contrib | |
parent | 4fe27144e3e78108b9ead03a256d1f7cf3e85557 (diff) | |
download | aerc-86eed28e65aed43a4b017f758405ca85fd74bf21.tar.gz |
contributing: add tooling for git send-email
Add a gitconfig target in the Makefile to configure a new clone with
sane defaults:
- set subject prefix
- set correct mailing list address
- enable sendemail.validate
- install sendemail-validate hook
The sendemail-validate hook will make a shallow clone of the current
upstream repo, apply every patch on it and run some checks (a stripped
down version of what is run by the upstream CI).
Add a new check-patches script that verifies that the commit message
actually contains something and that the Signed-off-by trailer from the
patch author is present.
Call check-patches in both the CI and the sendemail-validate hook.
Update CONTRIBUTING.md accordingly.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/check-patches | 39 | ||||
-rwxr-xr-x | contrib/sendemail-validate | 11 |
2 files changed, 50 insertions, 0 deletions
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 |