Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ runners need a few tools — see [Good to know](#good-to-know).
| `author-email` | `false` | Check each commit's author email |
| `pr-title` | `false` | Check the pull request title against Conventional Commits — the one that matters for squash merges. Pull request events only |
| `message-ai-attribution` | `false` | Check every commit against the AI rules of `cchk.toml` (`ai_attribution`) only, author included, without the format rules. Takes the place of `message` |
| `pr-body-ai-attribution` | `false` | Check the pull request description against the AI rules of `cchk.toml` (`ai_attribution`) only. Pull request events only |
| `pr-body-ai-attribution` | `false` | Check the pull request description against the AI rules of `cchk.toml` (`ai_attribution`, and the AI declaration boxes of `[pull_request] ai_declaration_checkboxes`) only. Pull request events only |
| `ai-label` | `false` | Label the pull request when an AI tool wrote any of it (a commit, the description, or an agent's app that opened it): `true` for `ai-assisted`, or the label's name. Labels are only added, never removed. Needs `pull-requests: write`; skipped on fork pull requests under `pull_request` |
| `pr-comments` | `false` | Post the report as a pull request comment, edited in place on later runs. Needs `pull-requests: write`; skipped on fork pull requests |
| `job-summary` | `true` | Write the report to the job summary |
Expand Down Expand Up @@ -212,6 +212,20 @@ the line to remove:
> - Co-Authored-By: Claude <noreply@anthropic.com>
> ```

If your pull request template asks the author to tick "No AI tools were used"
or "AI tools were used", name those boxes and the description must tick exactly
one of them (CC501). An empty description fails too:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

```toml
[pull_request]
ai_declaration_checkboxes = ["No AI tools were used", "AI tools were used"]
```

> ```diff
> @@ PR description @@
> # Tick the box that applies: "No AI tools were used" or "AI tools were used"
> ```

With `ai-label: true`, a pull request an AI tool wrote also gets the
`ai-assisted` label.

Expand Down
19 changes: 12 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +994,20 @@ def run_commit_check() -> tuple[int, list[ScopeResult]]:
# ---- 2. PR description ------------------------------------------------
if (PR_BODY_AI_ATTRIBUTION_ENABLED or ai_label_name()) and is_pr_event():
pr_body = get_pr_body()
if pr_body:
if PR_BODY_AI_ATTRIBUTION_ENABLED:
# An empty description is checked too: it has no AI declaration,
# which CC501 fails when [pull_request] ai_declaration_checkboxes
# names the boxes. The attribution rules pass empty text.
scope = check_scope(
"PR description", ["--ai-attribution-only"], input_text=pr_body or ""
)
name_the_line_changes(scope, pr_body or "")
results.append(skip_when_no_ai_rule_ran(scope))
elif pr_body:
scope = check_scope(
"PR description", ["--ai-attribution-only"], input_text=pr_body
)
if PR_BODY_AI_ATTRIBUTION_ENABLED:
name_the_line_changes(scope, pr_body)
results.append(skip_when_no_ai_rule_ran(scope))
else:
PR_BODY_AI_TOOLS[:] = scope.ai_tools
PR_BODY_AI_TOOLS[:] = scope.ai_tools

# ---- 3. Commit message checks -----------------------------------------
pr_commits: list[Commit] | None = None
Expand Down Expand Up @@ -1971,7 +1976,7 @@ def _all_checks(results: list[ScopeResult]) -> list[str]:
#
# </details>
#
# <sub>Checked by [Commit Check](https://commit-check.com) 2.20.5 · [Rules](…) · [Check before you push](…)</sub>
# <sub>Checked by [Commit Check](https://commit-check.com) 2.21.0 · [Rules](…) · [Check before you push](…)</sub>
#
# Success: the heading reads "<mark:passed> Commit Check passed", then the
# group lines, the folded listing and the footer. No diff, no "How to fix".
Expand Down
10 changes: 9 additions & 1 deletion main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4604,8 +4604,16 @@ def test_off_by_default(self):
mock_scope.assert_not_called()
self.assertEqual(results, [])

def test_no_description_nothing_to_check(self):
def test_no_description_is_checked_as_empty_text(self):
"""A description left empty has no AI declaration for CC501 to find."""
results, mock_scope = self._run(True, "true", body=None)
mock_scope.assert_called_once_with(
"PR description", ["--ai-attribution-only"], input_text=""
)
self.assertEqual([r.label for r in results], ["PR description"])

def test_no_description_nothing_to_label(self):
results, mock_scope = self._run(False, "true", body=None)
mock_scope.assert_not_called()
self.assertEqual(results, [])

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install commit-check CLI
# For details please see: https://github.com/commit-check/commit-check
commit-check==2.20.5
commit-check==2.21.0
# Interact with the GitHub API.
PyGithub==2.10.0
Loading