From a1feb79e88e3d43d7f1ed341a74fd4896a87aba1 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Tue, 8 Nov 2022 19:12:45 -0500 Subject: [PATCH] common/scripts/lint-commits: check commit author github account --- .github/workflows/build.yaml | 1 + common/scripts/lint-commits | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 95f1cd88e338..454ffbaf2680 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -24,6 +24,7 @@ jobs: PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' XLINT: '1' LICENSE_LIST: common/travis/license.lst + GH_PR_NUM: ${{ github.event.number }} steps: - uses: actions/checkout@v1 diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits index 6aea99d51154..582d44c79ca1 100755 --- a/common/scripts/lint-commits +++ b/common/scripts/lint-commits @@ -37,7 +37,7 @@ do (NF > 2) && (length > 80) { print "::error title=Commit Lint::" C ": long line: " $0; exit 1 } !subject { if (length > 50) { print "::warning title=Commit Lint::" C ": subject is a bit long" } - if (!($0 ~ ":" || $0 ~ "^Take over maintainership " || $0 ~ "^Orphan ")) { print "::error title=Commit Lint::" C ": subject does not follow CONTRIBUTING.md guildelines"; exit 1 } + if (!($0 ~ ":" || $0 ~ "^Take over maintainership " || $0 ~ "^Orphan ")) { print "::error title=Commit Lint::" C ": subject does not follow CONTRIBUTING.md guidelines"; exit 1 } # Below check is too noisy? # if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) { # print "::warning title=Commit Lint::" C ": not new package/update/removal?" @@ -48,4 +48,14 @@ do !body { print "::error title=Commit Lint::" C ": second line must be blank"; exit 1 } ' || status=1 done + +if [ "$GITHUB_ACTIONS" = "true" ] && [ "$GH_PR_NUM" ]; then + gh api repos/void-linux/void-packages/pulls/$GH_PR_NUM/commits -t "{{range .}}{{slice .sha 0 8}}:{{.committer.login}}:{{.author.login}}{{end}}" | + awk -F: ' + BEGIN { E=0 } + ($1 ~ /^$/) { print "::error title=Commit Lint::" $0 ": no GitHub account associated with committer"; E=1 } + ($2 ~ /^$/) { print "::error title=Commit Lint::" $0 ": no GitHub account associated with commit author"; E=1 } + END { exit $E }' || status=1 +fi + exit $status