Skip to content

ci: skip merge commits in commit-message lint#90

Merged
cyfyifanchen merged 1 commit into
mainfrom
ci/skip_merge_commits_in_lint
Jul 3, 2026
Merged

ci: skip merge commits in commit-message lint#90
cyfyifanchen merged 1 commit into
mainfrom
ci/skip_merge_commits_in_lint

Conversation

@JasonJarvan

Copy link
Copy Markdown
Contributor

Summary

The commit-message lint rejects any Merge ... commit in the PR range
(scripts/commit_lint.py: "merge commits are not allowed in PR ranges").
But this repository is squash-only (rebase/merge disabled), so a merge
commit created by syncing main into a feature branch is squashed away at
merge time and never reaches main. The rule therefore guards nothing while
failing the CI check for every PR that synced main via a merge commit
(observed on #82).

The fix makes scripts/check_commit_messages.py gather only non-merge
commits by passing --no-merges to its git log call, mirroring
commitlint's own default of ignoring merge commits. The Merge rule in
commit_lint.py is left intact as belt-and-suspenders (it is also reused by
the PR-title path), so no lint behavior is removed.

Type

  • Fix
  • Feature
  • Docs
  • CI / tooling
  • Refactor
  • Other

Verification

  • uv run pytest tests/test_check_commit_messages.py tests/test_commit_lint.py -q -> 10 passed

  • uv run ruff check scripts/check_commit_messages.py tests/test_check_commit_messages.py -> All checks passed

  • Added TDD coverage in tests/test_check_commit_messages.py: builds a real
    temporary repo with a --no-ff merge commit and asserts the range passes
    (red before the fix, green after).

  • Relevant tests pass locally

  • Relevant lint / type checks pass locally

  • User-facing docs or screenshots are updated when needed

Risk

  • Security impact considered
  • Backward compatibility considered
  • Rollback path is clear for risky changes

Backward compatible: real commit messages are still linted exactly as
before; only merge commits are now skipped. Rollback is a one-line revert of
the --no-merges flag.

Related Issues

N/A

Co-authored-by: Claude (claude-opus-4-8) [email protected]

The commit-message check rejected any Merge commit in the PR range, but the
repository is squash-only so merge commits never reach main. Every PR that
synced main via a merge commit failed the check for no benefit. Gather only
non-merge commits with git log --no-merges, mirroring commitlint's default,
while leaving the belt-and-suspenders Merge rule in commit_lint.py intact.

Co-authored-by: Claude (claude-opus-4-8) <[email protected]>
@cyfyifanchen cyfyifanchen merged commit 8a2aca0 into main Jul 3, 2026
7 checks passed
@cyfyifanchen cyfyifanchen deleted the ci/skip_merge_commits_in_lint branch July 3, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants