commit-check 2.24.0__py3-none-any.whl → 2.24.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
commit_check/engine.py CHANGED
@@ -87,6 +87,25 @@ def is_revert_subject(subject: str) -> bool:
87
87
  return _GIT_REVERT_SUBJECT.match(subject) is not None
88
88
 
89
89
 
90
+ # "git commit --fixup" writes "fixup! <subject>", "--squash" writes
91
+ # "squash! <subject>" and "--fixup=amend:"/"--fixup=reword:" write
92
+ # "amend! <subject>", each in front of the target commit's subject.
93
+ # "git rebase --autosquash" folds these commits into their target, so the
94
+ # subject behind the prefix is one already judged on its own commit, or,
95
+ # after "amend! ", one about to be replaced. Git writes the prefix exactly
96
+ # so, trailing space included: "fixup!! ..." or "Fixup! ..." is the author's.
97
+ _GIT_AUTOSQUASH_SUBJECT = re.compile(r"^(?:fixup|squash|amend)! ")
98
+
99
+
100
+ def is_autosquash_subject(subject: str) -> bool:
101
+ """Whether *subject* is one ``git commit --fixup`` or ``--squash`` wrote.
102
+
103
+ The subject rules decline to judge these, as they do a merge or revert
104
+ subject. Whether they are allowed at all is ``allow_fixup_commits``'.
105
+ """
106
+ return _GIT_AUTOSQUASH_SUBJECT.match(subject) is not None
107
+
108
+
90
109
  # A work-in-progress marker at the start of the subject (CC010). "^" without
91
110
  # re.MULTILINE and "[ \t]*" rather than "\s*" keep the match on the first
92
111
  # line, so a body that merely mentions WIP is not a WIP commit.
@@ -582,10 +601,11 @@ class SubjectCapitalizationValidator(SubjectValidator):
582
601
  """Validates that subject starts with capital letter."""
583
602
 
584
603
  def _validate_subject(self, subject: str) -> ValidationResult:
585
- # A merge subject is machine-written; the rule declines to judge it.
586
- # Only the subjects merge tools write count, so anything else is
604
+ # Merge and fixup subjects are machine-written; the rule declines to
605
+ # judge them. Only the subjects merge tools write, and git's exact
606
+ # "fixup! ", "squash! " and "amend! ", count, so anything else is
587
607
  # author prose.
588
- if is_merge_subject(subject):
608
+ if is_merge_subject(subject) or is_autosquash_subject(subject):
589
609
  return ValidationResult.SKIP
590
610
 
591
611
  if self._is_capitalized(subject):
@@ -629,8 +649,8 @@ class SubjectImperativeValidator(SubjectValidator):
629
649
  def _validate_subject(self, subject: str) -> ValidationResult:
630
650
  # Merge and fixup subjects are machine-written; decline to judge them.
631
651
  # Only the subjects merge tools write, and git's exact "fixup! ",
632
- # count, so anything else is author prose.
633
- if is_merge_subject(subject) or subject.startswith("fixup! "):
652
+ # "squash! " and "amend! ", count, so anything else is author prose.
653
+ if is_merge_subject(subject) or is_autosquash_subject(subject):
634
654
  return ValidationResult.SKIP
635
655
 
636
656
  # Extract first word, past a Conventional Commits prefix (including
@@ -728,10 +748,14 @@ class SubjectLengthValidator(SubjectValidator):
728
748
  return True
729
749
 
730
750
  def _validate_subject(self, subject: str) -> ValidationResult:
731
- # A merge or revert subject's length is git's doing, not the
751
+ # A merge, revert or fixup subject's length is git's doing, not the
732
752
  # author's: 'Revert "..."' adds nine characters to a subject that
733
- # already fit.
734
- if is_merge_subject(subject) or is_revert_subject(subject):
753
+ # already fit, and "fixup! " seven.
754
+ if (
755
+ is_merge_subject(subject)
756
+ or is_revert_subject(subject)
757
+ or is_autosquash_subject(subject)
758
+ ):
735
759
  return ValidationResult.SKIP
736
760
 
737
761
  suffix = _SQUASH_PR_NUMBER.search(subject)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commit-check
3
- Version: 2.24.0
3
+ Version: 2.24.2
4
4
  Summary: Commit policy as code for teams and AI agents: check commit messages, branch names, authors, tags, files and AI attribution.
5
5
  Author-email: Xianpeng Shen <xianpeng.shen@gmail.com>
6
6
  License-Expression: MIT
@@ -88,7 +88,7 @@ Stop bad commits before they exist. In `.pre-commit-config.yaml`:
88
88
  ```yaml
89
89
  repos:
90
90
  - repo: https://github.com/commit-check/commit-check
91
- rev: v2.24.0
91
+ rev: v2.24.2
92
92
  hooks:
93
93
  - id: check-message
94
94
  - id: check-branch
@@ -160,7 +160,7 @@ Priority: CLI > env > TOML > default. Booleans accept `true/false`, `yes/no`,
160
160
  | `commit.message_pattern` | `""` | — | `CCHK_MESSAGE_PATTERN` | Custom regex the whole message must match; when set it replaces the Conventional Commits check (still reported as CC001) |
161
161
  | `commit.subject_capitalized` | `false` | `--subject-capitalized` | `CCHK_SUBJECT_CAPITALIZED` | Require the subject to start with a capital letter (CC002) |
162
162
  | `commit.subject_imperative` | `false` | `--subject-imperative` | `CCHK_SUBJECT_IMPERATIVE` | Require the subject to use the imperative mood (CC003) |
163
- | `commit.subject_max_length` | `80` | `--subject-max-length` | `CCHK_SUBJECT_MAX_LENGTH` | Maximum subject length (CC004), not counting the ` (#123)` a GitHub squash merge adds; the `Revert "..."` and `Reapply "..."` subjects `git revert` writes are not measured; `0` turns it off. Commits by `dependabot[bot]` and `renovate[bot]` skip both length rules |
163
+ | `commit.subject_max_length` | `80` | `--subject-max-length` | `CCHK_SUBJECT_MAX_LENGTH` | Maximum subject length (CC004), not counting the ` (#123)` a GitHub squash merge adds; the `Revert "..."` and `Reapply "..."` subjects `git revert` writes, and the `fixup!`, `squash!` and `amend!` subjects `git commit --fixup` and `--squash` write, are not measured; `0` turns it off. Commits by `dependabot[bot]` and `renovate[bot]` skip both length rules |
164
164
  | `commit.subject_min_length` | `5` | `--subject-min-length` | `CCHK_SUBJECT_MIN_LENGTH` | Minimum subject length (CC005); `0` turns it off |
165
165
  | `commit.allow_commit_types` | `feat, fix, docs, style, refactor, test, chore, perf, build, ci, revert` | `--allow-commit-types` | `CCHK_ALLOW_COMMIT_TYPES` | Allowed `<type>` values in the subject |
166
166
  | `commit.allow_merge_commits` | `true` | `--allow-merge-commits` | `CCHK_ALLOW_MERGE_COMMITS` | Allow merge commits (CC006) |
@@ -7,7 +7,7 @@ commit_check/api.py,sha256=GYeRo2o_GgK90Srk9gaINcP8QGzXvB4atcp4ygxV2tQ,13920
7
7
  commit_check/ci.py,sha256=i9cIlMbIn_nHA4cln2YUgCReYm22efkPqKyjh-gq3kQ,19022
8
8
  commit_check/config.py,sha256=NaddFMR-nRPSpEyNN3FX0I1lq2WqF0JE7LHTlDEDe1U,14715
9
9
  commit_check/config_merger.py,sha256=sXOTAVaTY2-oRzvhS1NeQuPAqnM8XoGTVMDkY0z-vDA,15858
10
- commit_check/engine.py,sha256=vu17rYMj-AFXwDoYI1ejH741JvQwjAoQ2CdeidEeg14,101090
10
+ commit_check/engine.py,sha256=Yyh3xYdBJGKdONviD-PcmsQiCY0QRYydgE6hJNOJP_k,102258
11
11
  commit_check/fixes.py,sha256=BpbdoHsKDyw2WfsqymwYpnrW73aHdCDGr8tMF6Ho2RU,7305
12
12
  commit_check/imperatives.py,sha256=dEd_ssu4G0j6Cann6jqPdB97lw5Adua43K0_Odg_FyA,9518
13
13
  commit_check/main.py,sha256=uf32w7vRGPxN_GI5dadzeIuRft1dmRiUfOTnTmon63o,35284
@@ -15,9 +15,9 @@ commit_check/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  commit_check/rule_builder.py,sha256=mRYi3-4gJYgWOnQojVCDVbR0VMXHoBV92dB46w5RRMY,38645
16
16
  commit_check/rules_catalog.py,sha256=0jUT-e78me1RJAsxLHyzTCpVobKHjtNbmhnFvX5GsOc,14289
17
17
  commit_check/util.py,sha256=VE0qNx2HpyDB1CPFF_p7I2EOJzAPs_yKDCJ1zFyCdok,38710
18
- commit_check-2.24.0.dist-info/licenses/LICENSE,sha256=9mdTva71kQhrpWh_nZulxrdCnUrl5c6xJYh5hdo4p_s,1070
19
- commit_check-2.24.0.dist-info/METADATA,sha256=0IPtdMew9fCdDmSPo5nzjJIuOCRcXxGuy2RyLqNld5Y,20338
20
- commit_check-2.24.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
21
- commit_check-2.24.0.dist-info/entry_points.txt,sha256=-4RWjQDhmngfCnTx46iCz3RrI8WZoiMZo0nhsg6hmUw,125
22
- commit_check-2.24.0.dist-info/top_level.txt,sha256=Wf46u-ooHBMJNHbhfrBNQw3wC5_m8wt-o_Lfbc4QpRg,13
23
- commit_check-2.24.0.dist-info/RECORD,,
18
+ commit_check-2.24.2.dist-info/licenses/LICENSE,sha256=9mdTva71kQhrpWh_nZulxrdCnUrl5c6xJYh5hdo4p_s,1070
19
+ commit_check-2.24.2.dist-info/METADATA,sha256=j_fwgkvz7_5nbV5INcw6GyagIni2FMML3HCR1X2iJUQ,20432
20
+ commit_check-2.24.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
21
+ commit_check-2.24.2.dist-info/entry_points.txt,sha256=-4RWjQDhmngfCnTx46iCz3RrI8WZoiMZo0nhsg6hmUw,125
22
+ commit_check-2.24.2.dist-info/top_level.txt,sha256=Wf46u-ooHBMJNHbhfrBNQw3wC5_m8wt-o_Lfbc4QpRg,13
23
+ commit_check-2.24.2.dist-info/RECORD,,