fix(ci): exempt merge commits from the sign-off requirement - #556
Conversation
The check shipped in #554 flags every merge commit, because GitHub's "Update branch" and merge buttons author them with no `Signed-off-by` trailer and give the clicker no way to add one. This is not rare: 19 of the last 200 commits on `main` are merge commits and none of them carry a sign-off, and the merge commit added to #554 itself during review would have been flagged by the check that pull request introduced. A merge introduces no new authorship for the DCO to certify, so the exemption is sign-off only. Merge commits are still required to be signed, which they are, since GitHub signs the ones its buttons create. Verified against real payloads: #554's own commits now pass, a merge commit with an unsigned signature is still flagged, and #537 goes from 7 of 7 commits flagged to the 3 that are genuinely missing a sign-off, the other 4 being `Merge branch 'main'` commits. Signed-off-by: Brian Lockwood <lockwobr@gmail.com>
❌ Some commits are missing a sign-off or a signatureEvery commit in this repository must be signed off (
How to fixOne-time setup, so you only ever need # Commit identity, used in the Signed-off-by trailer.
# Use an address GitHub has verified on your account.
git config user.name "Your Name"
git config user.email "your.email@example.com"
# Signing key, separate from the identity above. For SSH:
git config gpg.format ssh
git config user.signingkey ~/.ssh/id_ed25519.pub
# Sign every commit from now on
git config commit.gpgsign trueThe key must also be registered with GitHub: see generating a GPG or SSH signing key. To fix the most recent commit: git commit --amend -s -S --no-edit
git push --force-with-lease origin 'fix/commit-requirements-merge-commits'To fix every commit on the branch at once. Check for merge commits first, because a plain rebase drops them: git log --oneline --merges origin/main..HEAD # empty output means linear
# Linear branch:
git rebase --exec 'git commit --amend -s -S --no-edit' origin/main
# Branch with merge commits, preserving them:
git rebase --rebase-merges --exec 'git commit --amend -s -S --no-edit' origin/mainConfirm the rewrite changed nothing but the signatures before pushing: git range-diff @{u}...HEAD
git push --force-with-lease origin 'fix/commit-requirements-merge-commits'Re-signing rewrites every commit, which outdates inline review comments. If the PR is already under review, leave a note saying you force-pushed. Full details are in CONTRIBUTING.md. This check reports but does not block your merge; a maintainer will still ask you to fix it. |
|
Note for reviewers: the failing Sign-off and signature check on this PR is the bug this PR fixes, not a problem with the fix.
The check cannot exercise the fix here: Running this branch's version of the script against this PR's own two commits: The check is otherwise behaving correctly: it identified the right commit, gave an accurate reason, and did not block the merge, since it deliberately publishes no |
Description
Follow-up to #554. The check it added flags every merge commit, so a pull request updated with GitHub's Update branch button fails through no fault of the author.
GitHub authors those merge commits itself with no
Signed-off-bytrailer, and the person clicking the button has no way to add one. This is not an edge case: 19 of the last 200 commits onmainare merge commits and not one carries a sign-off. The sharpest illustration is that the merge commit added to #554 during its own review (1e0cebfd,signoff=NO) would have been flagged by the check #554 introduced.That is the failure mode #554 was explicitly designed to avoid. A check that flags maintainers on its first day for something they cannot fix is a check everyone learns to ignore, which is the same reasoning used there to drop sign-off/author email matching.
The change
isMerge(c) => (c.parents?.length ?? 0) > 1, and the sign-off requirement is skipped for those commits.The exemption is sign-off only. A merge introduces no new authorship for the DCO to certify, but it still has to be signed, and GitHub signs the merges its buttons create.
parentsis already present in the payload the workflow fetches, so nothing new is requested.CONTRIBUTING.mdis updated in the same PR to keep the documented behaviour matching the code, which was a review point on #554.Testing
Ran the workflow's script against real API payloads:
Merge branch 'main'commits exemptedmainhead with bots[bot]git identity, sign-off quoted in proseThe #537 line is the point: the three genuinely unsigned-off commits are still reported, and the four merge commits that were drowning them out are not.
actionlintandmake license-header-checkare clean.Checklist
git commit -s -S.