Skip to content

fix: do not judge the fixup!, squash! and amend! subjects git writes - #734

Merged
shenxianpeng merged 2 commits into
mainfrom
fix/fixup-subject-rules
Nov 23, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
fix/fixup-subject-rules

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes #733.

git commit --fixup, --squash and --fixup=amend: put fixup! , squash! or amend! in front of the target commit's subject. The subject rules judged that prefix as if the author had written it:

  • CC004 counted it, so a fixup of a subject that fit the limit was rejected (the issue's case).
  • CC002 rejected every one of these commits for the lower-case fixup!, and suggested Fixup! ..., which git rebase --autosquash would no longer recognise.
  • CC003 already skipped fixup! , but not squash! or amend! .

CC002 to CC005 now skip these subjects, the same way they skip a merge or Revert "..." subject, and CC001 already exempts them. Whether they are allowed at all stays CC009's call (allow_fixup_commits). Only git's exact prefix counts: fixup!! ... or Fixup! ... is the author's and is still judged. Skipping, rather than measuring the rest of the line, also covers amend! , where the rest of the line is the subject being replaced.

Before (v2.24.0)

$ cat cchk.toml
[commit]
subject_max_length = 72
subject_capitalized = true

$ cat msg
fixup! feat(parser): accept trailing commas in the argument list of a call

$ commit-check --message msg
✖ Commit rejected by Commit Check · 2 checks failed

  │ fixup! feat(parser): accept trailing commas in the argument list of a call

✖ CC002 subject-capitalized failed
  Subject must start with a capital letter
  Suggest: Use "Fixup! feat(parser): accept trailing commas in the argument list of a call"
  Docs:    https://commit-check.com/rules/#cc002

✖ CC004 subject-max-length failed
  Subject is 74 characters; it must be at most 72 characters
  Suggest: Shorten the subject by 2 characters, to 72 or fewer
  Docs:    https://commit-check.com/rules/#cc004

exit 1

After

$ commit-check --message msg
⊘ skipped (not validated): subject-capitalized, subject-max-length, subject-min-length
exit 0

squash! and amend! behave the same; a stacked fixup! fixup! too.

Tests

New cases for CC002 and CC004 (each prefix, stacked prefixes, author look-alikes still judged), CC003 extended to squash!/amend!, and is_autosquash_subject itself. README's subject_max_length row names the new exemption; the site's rules and configuration pages follow after the release.

Summary by CodeRabbit

  • New Features
    • Commit subject capitalization, imperative, and length checks now skip subjects beginning with Git’s fixup!, squash!, or amend! prefixes. These checks recognize the prefixes only in their expected form; author-written lookalikes are still checked. The existing policy for allowing fixup commits is unchanged.
  • Documentation
    • The configuration reference now clarifies that the subject length limit excludes these autosquash subjects, in addition to the previously documented exceptions.

git commit --fixup, --squash and --fixup=amend: put "fixup! ", "squash! "
or "amend! " in front of the target commit's subject. CC004 counted that
prefix, so a fixup of a subject that fit the limit was rejected, and CC002
rejected every one of them for its lower-case "fixup!". CC003 skipped only
"fixup! ".

The subject rules (CC002-CC005) now skip these subjects, as they skip a
merge or revert subject. Whether they are allowed stays CC009's call.

Closes #733
@shenxianpeng
shenxianpeng requested a review from a team as a code owner November 23, 2026 12:31
@github-actions github-actions Bot added the bug Something isn't working label Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The engine recognizes lowercase fixup! , squash! , and amend! prefixes. Capitalization, imperative, and subject-length validators skip these subjects. Tests cover recognized prefixes and malformed lookalikes. The README documents the length-rule behavior.

Changes: Autosquash subject validation

Layer / File(s) Summary
Recognize and skip autosquash subjects
commit_check/engine.py, tests/engine_test.py, README.md
The engine detects exact autosquash prefixes and skips these subjects in capitalization, imperative, and length validation. Tests cover valid and malformed prefixes. The README documents the length-rule exclusion.

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to edca9

Git-generated fixup, squash and amend subjects are no longer judged by the capitalization, imperative and length rules. Lookalike subjects remain checked. No actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: Git-generated fixup!, squash! and amend! subjects are no longer judged by the subject rules. The raw summary and objectives confirm that engine.py skips these subjects…
Linked Issues check Passed Issue #733 is the only directly linked issue and it is open. Its requirement is that CC004 (subject-max-length) not count git's fixup! prefix, so a fixup of a subject within the limit passes. It al…
Out of Scope Changes check Passed All changes support issue #733 and the PR objective:
- commit_check/engine.py: adds is_autosquash_subject. Uses it in SubjectCapitalizationValidator (CC002), SubjectImperativeValidator (CC003, rep…
Full details: Title check

Explanation

The title names the main change: Git-generated fixup!, squash! and amend! subjects are no longer judged by the subject rules. The raw summary and objectives confirm that engine.py skips these subjects in the capitalization, imperative, and length checks, and that tests cover them. The 'fix:' prefix matches the change's bug-fix intent, since issue #733 reports a false failure.

Full details: Linked Issues check

Explanation

Issue #733 is the only directly linked issue and it is open. Its requirement is that CC004 (subject-max-length) not count git's fixup! prefix, so a fixup of a subject within the limit passes. It also asks whether squash! and amend! can be handled the same way, and notes that amend! may need the whole subject skipped.

At the reviewed head, commit_check/engine.py adds is_autosquash_subject, which matches ^(?:fixup|squash|amend)! at the start of the subject. SubjectLengthValidator._validate_subject returns SKIP for these subjects, so CC004 no longer measures them. This meets the CC004 case in the issue and the amend! case, because the whole subject is skipped and not only the prefix. The regex requires the exact prefix with a trailing space, so fixup!! and Fixup! are still judged. Tests in tests/engine_test.py cover these cases according to the change summary. The test results were not run during this review.

No unmet coding requirement is found.

Full details: Out of Scope Changes check

Explanation

All changes support issue #733 and the PR objective:

  • commit_check/engine.py: adds is_autosquash_subject. Uses it in SubjectCapitalizationValidator (CC002), SubjectImperativeValidator (CC003, replacing the earlier startswith("fixup! ") check), and SubjectLengthValidator (CC004). The min-length check (CC005) appears in the example output as skipped. This is consistent with the length validator covering both limits, but the min-length path was not separately inspected.
  • tests/engine_test.py: tests for the new behavior and the predicate. Supporting tests for the implementation.
  • README.md: one-line update to the subject_max_length row describing the exemption. Documentation of the implemented behavior.

The PR does not change CC009 or allow_fixup_commits, which the PR states remains unchanged. No unrelated change is found.

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: 0725d5b1-515e-4052-9dd7-53123474040b
Commits

Reviewing files that changed from the base of the PR and between dabd45b and edca97e.

Files selected for processing: 1

  • tests/engine_test.py

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

@shenxianpeng shenxianpeng self-assigned this Nov 23, 2026
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (87cf6e5) to head (edca97e).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #734   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         3156      3159    +3     
  Branches       626       626           
=========================================
+ Hits          3156      3159    +3     

☔ 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 23, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 133 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
⏩ 132 skipped benchmarks1


Comparing fix/fixup-subject-rules (edca97e) with main (4032000)2

Open in CodSpeed

Footnotes

  1. 132 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. ↩

  2. No successful run was found on main (87cf6e5) during the generation of this report, so 4032000 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Move the squash! and amend! cases into their own test, so the benchmarked
one measures the same two calls as on main.
@sonarqubecloud

Copy link
Copy Markdown

@shenxianpeng
shenxianpeng merged commit e8bd51a into main Nov 23, 2026
34 checks passed
@shenxianpeng
shenxianpeng deleted the fix/fixup-subject-rules branch November 23, 2026 13:20
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.

subject_max_length counts git's fixup! prefix, so a fixup of a subject that fits is rejected

1 participant