fix: Skip merge commits in DCO sign-off check#1202
Conversation
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
|
Hi, this is DCO Bot! 👋 I noticed some commits on this PR are missing the required DCO sign-off. Here are the ones that need attention:
Please add a line |
…mits Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
|
Hi @rwalworth 👋, thank you for submitting this PR! This comment will stay updated as you make changes. PR Checks❌ DCO Sign-off -- The following commits are missing the required DCO sign-off:
Please add ✅ GPG Signature -- All commits have verified GPG signatures. ✅ Merge Conflicts -- No merge conflicts detected. ✅ Issue Link -- Linked to #1199 (assigned to you). All checks must pass before this PR can be reviewed. |
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Summary
This PR fixes the DCO (Developer Certificate of Origin) bot to skip merge commits when
validating sign-off lines. Merge commits are auto-generated by Git and do not contain
original work, so DCO sign-off should not be required for them.
Fixes #1199.
Motivation
In PR #1198, the bot flagged commit
b41b844(Merge branch 'main' into feat/getAccountInfo-jsonRpc#669) as missing DCO sign-off. This is a false positive - merge commits have more than one parent and are generated by Git, not authored by a contributor. The DCO check should exempt them.Changes
isMergeCommitHelperAdded a new
isMergeCommit(commit)function inchecks.jsthat detects merge commitsby checking whether the
parentsarray has more than one entry (the standard GitHub APIrepresentation of a merge commit):
checkDCOUpdateUpdated the
checkDCOloop to skip merge commits before checking for aSigned-off-by:line. The log message now reports how many merge commits were skipped for transparency:
Only the DCO check is affected — the GPG signature check and merge conflict check are
unchanged, as the issue requires.
Test Utilities
Added a
commitMerge(sha, message)factory totest-utils.jsthat creates a mergecommit object (two parents, no DCO sign-off, verified GPG) for use in tests.
Unit Tests (6 + 3 new)
Added to
test-checks.js:isMergeCommit: commit with two parents returns trueisMergeCommit: commit with one parent returns falseisMergeCommit: commit with no parents field returns falseisMergeCommit: null commit returns falseisMergeCommit: undefined commit returns falseisMergeCommit: commit with empty parents array returns falsecheckDCO: merge commit without sign-off is skipped (passes)checkDCO: merge commit skipped, regular commits still checkedcheckDCO: all regular commits pass with merge commit presentIntegration Tests (2 new)
Added to
test-on-pr-update-bot.js:[sync] Merge commit without DCO sign-off is skipped[edit] Merge commit without DCO sign-off is skippedTesting
Test Plan:
isMergeCommitcorrectly identifies merge vs. non-merge commitscheckDCOskips merge commits and still flags unsigned regular commitsFiles Changed Summary
.github/scripts/helpers/checks.jsisMergeCommithelper +checkDCOupdate.github/scripts/tests/test-utils.jscommitMergefactory.github/scripts/tests/test-checks.js.github/scripts/tests/test-on-pr-update-bot.jsBreaking Changes
None. The only behavioral change is that merge commits are no longer flagged by the
DCO check. All other checks (GPG, merge conflict, issue link) are unaffected.