diff options
author | Robin Jarry <robin@jarry.cc> | 2024-01-17 23:06:39 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-01-18 22:07:13 +0100 |
commit | 7d28813d730fd2d4216a3b3365b0a5ec6f627d51 (patch) | |
tree | db096cb4e887b4244b31aead09c458339559f223 | |
parent | 430dd0022c92ee6cfca47b090aa7c558f7f54cb9 (diff) | |
download | aerc-7d28813d730fd2d4216a3b3365b0a5ec6f627d51.tar.gz |
check-patches: factorize code
Reduce code duplication.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com>
-rwxr-xr-x | contrib/check-patches | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/check-patches b/contrib/check-patches index 0fb2aa89..741dd5b8 100755 --- a/contrib/check-patches +++ b/contrib/check-patches @@ -12,28 +12,33 @@ if [ "$total" -eq 0 ]; then fi n=0 +title= +fail=false + +err() { + echo "error [PATCH $n/$total] '$title' $*" >&2 + fail=true +} + for rev in $revisions; do n=$((n + 1)) title=$(git log --format='%s' -1 "$rev") fail=false if [ "$(echo "$title" | wc -m)" -gt 72 ]; then - echo "error [PATCH $n/$total] '$title' title is longer than 72 characters, please make it shorter" >&2 - fail=true + err "title is longer than 72 characters, please make it shorter" fi author=$(git log --format='%an <%ae>' -1 "$rev") - if ! git log --format="%(trailers:key=Signed-off-by,only,valueonly)" -1 "$rev" | + if ! git log --format="%(trailers:key=Signed-off-by,only,valueonly,unfold)" -1 "$rev" | grep -qFx "$author"; then - echo "error [PATCH $n/$total] '$title' 'Signed-off-by: $author' trailer is missing" >&2 - fail=true + err "'Signed-off-by: $author' trailer is missing" fi 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 [PATCH $n/$total] '$title' body has less than three words, please describe your changes" >&2 - fail=true + err "body has less than three words, please describe your changes" fi if [ "$fail" = true ]; then |