GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: name the AI-rules-only option --ai-attribution-only (#677) · commit-check/commit-check@9aba6ad

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • commit_check
    • engine.py
    • main.py
    • rules_catalog.py
  • tests
    • main_test.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ author is on an `ignore_authors` list: `"author dependabot[bot] is in [commit].i
184184

185185
With a message checked, the output also has `ai_tools`: the AI tools found by
186186
their known signatures in the message (and by a commit's author), under any
187-
`ai_attribution` policy. `--ai-only` runs only the AI rules (CC013 to CC016),
187+
`ai_attribution` policy. `--ai-attribution-only` runs only the AI rules (CC013 to CC016),
188188
for text that is not a commit message, such as a pull request description.
189189
Under the default `ai_attribution = "ignore"` no AI rule runs, so the result
190190
passes and only `ai_tools` reports what was found; set `forbid` or `disclose`
191191
to enforce a policy:
192192

193193
```bash
194-
commit-check --ai-only --format json < pr-description.md
194+
commit-check --ai-attribution-only --format json < pr-description.md
195195
```
196196

197197
Validate a commit message with the Python API, without a subprocess:
Collapse file

‎commit_check/engine.py‎

Copy file name to clipboardExpand all lines: commit_check/engine.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ValidationContext:
131131
# commits the remote lacks, so a ref pushed alongside it -- a tag that
132132
# ``git push --follow-tags`` sends after a branch -- is not in the line.
133133
push_from_pre_commit: bool = False
134-
# Set by --ai-only: the text is not a commit message (a pull request
134+
# Set by --ai-attribution-only: the text is not a commit message (a pull request
135135
# description, say), so advice must not tell the reader to re-commit.
136136
not_a_commit: bool = False
137137

Collapse file

‎commit_check/main.py‎

Copy file name to clipboardExpand all lines: commit_check/main.py
+14-5Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,19 @@ def _get_parser() -> argparse.ArgumentParser:
191191
)
192192

193193
check_group.add_argument(
194-
"--ai-only",
194+
"--ai-attribution-only",
195195
action="store_true",
196196
help="check only the AI attribution of the message (CC013 to CC016), "
197197
"for text that is not a commit message, such as a pull request "
198198
"description; implies --message",
199199
)
200+
# The name it shipped with in 2.20.1, kept so existing scripts still work.
201+
check_group.add_argument(
202+
"--ai-only",
203+
dest="ai_attribution_only",
204+
action="store_true",
205+
help=argparse.SUPPRESS,
206+
)
200207

201208
check_group.add_argument(
202209
"-b",
@@ -688,7 +695,9 @@ def _get_requested_checks(args: argparse.Namespace) -> set[str]:
688695
requested_checks: set[str] = set()
689696

690697
if args.message:
691-
requested_checks |= AI_TEXT_CHECKS if args.ai_only else MESSAGE_CHECKS
698+
requested_checks |= (
699+
AI_TEXT_CHECKS if args.ai_attribution_only else MESSAGE_CHECKS
700+
)
692701
if args.branch:
693702
requested_checks |= BRANCH_CHECKS
694703
if args.tag:
@@ -742,7 +751,7 @@ def _run_json_output(
742751
"checks": [o.to_dict() for o in outcomes],
743752
}
744753
if args.message:
745-
report["ai_tools"] = ai_tools_in(context, author=not args.ai_only)
754+
report["ai_tools"] = ai_tools_in(context, author=not args.ai_attribution_only)
746755
print(json.dumps(report, indent=2))
747756
# Only a failure is an error. A skipped run validated nothing, but that
748757
# is not a policy violation, so it must not turn into a non-zero exit.
@@ -759,7 +768,7 @@ def main() -> int:
759768

760769
try:
761770
# Handle positional commit_msg_file argument for pre-commit compatibility
762-
if args.commit_msg_file or args.ai_only:
771+
if args.commit_msg_file or args.ai_attribution_only:
763772
args.message = True
764773

765774
if args.rev is not None:
@@ -870,7 +879,7 @@ def main() -> int:
870879
and (stdin_content is None or stdin_is_message),
871880
stdin_is_message=stdin_is_message,
872881
push_from_pre_commit=push_from_pre_commit,
873-
not_a_commit=args.ai_only,
882+
not_a_commit=args.ai_attribution_only,
874883
)
875884

876885
# Run validation – choose output mode based on --format
Collapse file

‎commit_check/rules_catalog.py‎

Copy file name to clipboardExpand all lines: commit_check/rules_catalog.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def docs_url(self) -> str | None:
326326
for entry in COMMIT_RULES
327327
if entry.check not in {"author_name", "author_email", "ignore_authors"}
328328
)
329-
#: What ``--ai-only`` runs: the AI attribution a text makes (CC013 to CC016),
329+
#: What ``--ai-attribution-only`` runs: the AI attribution a text makes (CC013 to CC016),
330330
#: for text that is not a commit, such as a pull request description. CC017
331331
#: is left out: it judges a commit's author, which such text does not have.
332332
AI_TEXT_CHECKS: frozenset[str] = frozenset(
Collapse file

‎tests/main_test.py‎

Copy file name to clipboardExpand all lines: tests/main_test.py
+30-6Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,8 +2242,8 @@ def test_the_message_or_the_type_is_printed(
22422242
assert capsys.readouterr().err == expected
22432243

22442244

2245-
class TestAiOnly:
2246-
"""``--ai-only``: the AI rules on text that is not a commit message."""
2245+
class TestAiAttributionOnly:
2246+
"""``--ai-attribution-only``: the AI rules on text that is not a commit message."""
22472247

22482248
BODY = (
22492249
"This adds a parser.\n\n"
@@ -2264,7 +2264,7 @@ def test_only_the_ai_rules_run(self, mocker, capsys, monkeypatch, pinned_author)
22642264
capsys,
22652265
monkeypatch,
22662266
self.BODY,
2267-
"--ai-only",
2267+
"--ai-attribution-only",
22682268
"--ai-attribution",
22692269
"forbid",
22702270
)
@@ -2287,7 +2287,7 @@ def test_under_disclose_the_three_rules_run(
22872287
capsys,
22882288
monkeypatch,
22892289
"This adds a parser.\n\nAssisted-by: Claude Code\n",
2290-
"--ai-only",
2290+
"--ai-attribution-only",
22912291
"--ai-attribution",
22922292
"disclose",
22932293
)
@@ -2302,7 +2302,9 @@ def test_ignore_runs_nothing_but_still_names_the_tools(
23022302
self, mocker, capsys, monkeypatch, pinned_author
23032303
):
23042304
"""Label-only: no verdict, but the tools are reported."""
2305-
rc, data = self._run_json(mocker, capsys, monkeypatch, self.BODY, "--ai-only")
2305+
rc, data = self._run_json(
2306+
mocker, capsys, monkeypatch, self.BODY, "--ai-attribution-only"
2307+
)
23062308
assert rc == 0
23072309
assert data["status"] == "pass"
23082310
assert data["checks"] == []
@@ -2319,13 +2321,35 @@ def test_the_author_is_not_judged(self, mocker, capsys, monkeypatch):
23192321
capsys,
23202322
monkeypatch,
23212323
"This adds a parser.\n",
2322-
"--ai-only",
2324+
"--ai-attribution-only",
23232325
"--ai-attribution",
23242326
"forbid",
23252327
)
23262328
assert rc == 0
23272329
assert data["ai_tools"] == []
23282330

2331+
def test_the_old_name_still_works(self, mocker, capsys, monkeypatch, pinned_author):
2332+
"""``--ai-only``, the name it shipped with in 2.20.1, is a hidden alias."""
2333+
rc, data = self._run_json(
2334+
mocker,
2335+
capsys,
2336+
monkeypatch,
2337+
self.BODY,
2338+
"--ai-only",
2339+
"--ai-attribution",
2340+
"forbid",
2341+
)
2342+
assert rc == 1
2343+
assert [c["rule_id"] for c in data["checks"]] == ["CC013"]
2344+
2345+
def test_the_old_name_is_not_in_the_help(self, capsys, monkeypatch):
2346+
monkeypatch.setattr("sys.argv", [CMD, "--help"])
2347+
with pytest.raises(SystemExit):
2348+
main()
2349+
out = capsys.readouterr().out
2350+
assert "--ai-attribution-only" in out
2351+
assert "--ai-only" not in out
2352+
23292353

23302354
class TestAiToolsInJson:
23312355
"""``ai_tools`` names the AI tools of a checked message, whatever the policy."""

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.