pkgcheck-comment closes a pull request only after pkgcheck has finished, and its check is not attached to the pull request, so a maintainer could merge before it ran. A commits job in pkgcheck fails on the same rules and can be required before merging. Both read the rules from scripts/commit-rules.sh. Signed-off-by: Zakk <zakk@gentoozh.org>
14 lines
809 B
Bash
Executable File
14 lines
809 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# usage: commit-rules.sh <pull request number>
|
|
# prints the commits of the pull request that break the commit rules in CONTRIBUTING.en.md
|
|
set -euo pipefail
|
|
# shellcheck disable=SC2016 # jq, not shell, expands these
|
|
gh api "repos/$REPO/pulls/${1:?pull request number}/commits?per_page=100" --paginate --jq '
|
|
.[] | (.commit.message | split("\n")[0]) as $s
|
|
| if (.parents | length) > 1 then ["It is a merge commit"]
|
|
else [ if ($s | test("^(Revert \"|[^\\s:][^:]*: \\S)")) then empty else "The subject does not start with what it changes" end,
|
|
if (.commit.message | test("(?m)^Signed-off-by: \\S")) then empty else "It has no `Signed-off-by:` line" end ]
|
|
end as $why
|
|
| select($why | length > 0)
|
|
| "- `\(.sha[0:12])` \($s)\n" + ($why | map(" - " + .) | join("\n"))'
|