Skip to content

fix: let git's revert subjects through and accept the revert type - #724

Merged
shenxianpeng merged 3 commits into
mainfrom
fix/revert-subjects
Nov 20, 2026
Merged

shenxianpeng merged 3 commits into
mainfrom
fix/revert-subjects

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

This fixes three ways a revert is rejected today.

  • Reapply "..." fails CC001. Since git 2.43, git revert writes Reapply "<subject>" when the commit it reverts is itself a revert. CC001 exempted only Revert ", so it now exempts Reapply " the same way. CC007 also counts it as a revert, so allow_revert_commits = false still rejects it.
  • CC004 measures git's wrapper. Revert "..." adds 9 characters, so a subject that fit the limit was rejected once reverted. The length rules now skip Revert " and Reapply " subjects, as they already skip merge subjects. A subject that only starts with the word ("Revert the parser change ...") is still measured.
  • revert: is not a default type. v1 accepted revert: ..., the Conventional Commits FAQ recommends it for a revert written by hand, and 16 owners in public configs add it back to allow_commit_types by hand. It is now in the default list.

GitHub's and GitLab's revert buttons write the same Revert "<subject>" subject as git.

Before / after

before and after

Tests

New tests cover Reapply under CC001 and CC007, the length rules skipping both git subjects but not prose, and revert: / revert(scope): passing the default config. Engine and rule builder tests: 700 passed.

The site docs (default type list, CC004 and CC007 rows, and the migration note telling v1 users to add revert back) go in a separate commit-check.com PR to merge with the release.

Summary by CodeRabbit

  • Bug Fixes

    • Git-generated Revert and Reapply commits are now handled consistently in commit validation. They’re accepted by default, and the setting to disallow revert commits also disallows reapply commits.
    • Git-generated revert and reapply subjects are excluded from subject-length checks; ordinary commit prose remains subject to the limit.
  • Documentation

    • Clarified how revert and reapply commits are treated, and added revert to the default allowed commit types.

git revert writes 'Reapply "..."' when the commit it reverts is itself a
revert (git 2.43+); CC001 now exempts it as it already did 'Revert "...".
CC007 counts it as a revert, so allow_revert_commits = false still
rejects it.

The subject length rules no longer measure 'Revert "..."' or
'Reapply "..."': the nine extra characters are git's, and a subject that
fit the limit was rejected once reverted.

revert joins the default commit types. v1 accepted "revert: ...", the
Conventional Commits FAQ recommends it for a hand-written revert, and
16 owners in public configs add it back by hand.
@shenxianpeng
shenxianpeng requested a review from a team as a code owner November 20, 2026 22:36
@github-actions github-actions Bot added the bug Something isn't working label Nov 20, 2026
@shenxianpeng shenxianpeng self-assigned this Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds recognition for Git-generated Revert and Reapply subjects. Commit validation skips these subjects for length checks and applies the revert-commit setting to both. Conventional-commit validation uses the shared subject pattern.

Changes: Git-generated revert subject handling

Layer / File(s) Summary
Revert subject pattern and matcher
commit_check/__init__.py, commit_check/engine.py
The default commit types include revert. A shared pattern and is_revert_subject helper recognize quoted Git-generated Revert and Reapply subjects.
Validation rules and coverage
commit_check/engine.py, commit_check/rule_builder.py, tests/engine_test.py, tests/rule_builder_test.py, README.md
Subject-length validation skips Git-generated revert subjects. The revert-commit check and conventional-commit exemption recognize Revert and Reapply subjects. Tests distinguish these from author-written prose, and the README documents the behavior.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Merge Risk: Minimal · up to 86f4f

This change lets Git-generated Revert and Reapply subjects pass commit checks and adds revert to the default types. It is a narrow, easily reversible change, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: Git-generated revert subjects are let through, and the revert type is accepted. The summary, objectives, and file changes all cover both. The title is specific an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the two main changes: Git-generated revert subjects are let through, and the revert type is accepted. The summary, objectives, and file changes all cover both. The title is specific and short, and it matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: db008ba3-e4be-4b5c-932f-dfe008eddedd
Commits

Reviewing files that changed from the base of the PR and between 029bf06 and 86f4f00.

Files selected for processing: 6

  • README.md
  • commit_check/__init__.py
  • commit_check/engine.py
  • commit_check/rule_builder.py
  • tests/engine_test.py
  • tests/rule_builder_test.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (029bf06) to head (86f4f00).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #724   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         3074      3078    +4     
  Branches       608       608           
=========================================
+ Hits          3074      3078    +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 134 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 685 untouched benchmarks
⏩ 131 skipped benchmarks1


Comparing fix/revert-subjects (86f4f00) with main (029bf06)

Open in CodSpeed

Footnotes

  1. 131 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@shenxianpeng
shenxianpeng merged commit 8263be1 into main Nov 20, 2026
35 checks passed
@shenxianpeng
shenxianpeng deleted the fix/revert-subjects branch November 20, 2026 23:14
shenxianpeng added a commit to commit-check/commit-check.com that referenced this pull request Nov 20, 2026
Docs for CLI v2.23.1, which ships commit-check/commit-check#724.

- **Pins:** every pre-commit `rev:` moves from `v2.23.0` to `v2.23.1`
(Configuration, Example, Compare, pre-commit guide). docs-sync checks
these against PyPI.
- **Changelog:** a v2.23.1 entry and a Highlights row: the message
quoted once over several failures (commit-check/commit-check#719), the
intro on a bare `commit-check` (commit-check/commit-check#718), and
git's revert subjects plus the `revert` type
(commit-check/commit-check#724).
- **Configuration:** `revert` is added to the `allow_commit_types`
default. The length rows say `Revert "..."` and `Reapply "..."` subjects
are not measured, and `allow_revert_commits` now names both subjects.
- **Rules:** CC001 accepts git's revert subjects and points hand-written
reverts to the `revert` type. CC004 lists them under "Not counted".
CC007 covers `Reapply "..."` too.
- **Migration:** the warning no longer tells v1 users to add `revert`
back. It keeps the `task` branch type.
- **Examples:** the sample CC001 output in Getting started, Example and
Other CI lists `revert`. The two-failure sample in the policy guide was
rerun on 2.23.1 and is unchanged.

`pytest tests/` (docs-sync, against commit-check 2.23.1 from PyPI) and
`nox -s docs` (`mkdocs build --strict`) pass locally.

---------

Co-authored-by: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant