diff --git a/README.md b/README.md index ae941c5..1127ea1 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ runners need a few tools — see [Good to know](#good-to-know). | `author-name` | `false` | Check each commit's author name | | `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 | -| `pr-body` | `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`) 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 | @@ -87,7 +87,7 @@ runners need a few tools — see [Good to know](#good-to-know). > [!TIP] > `pull_request` does not fire when a title or description is edited. With -> `pr-title` or `pr-body`, add `types: [opened, synchronize, reopened, edited]` +> `pr-title` or `pr-body-ai-attribution`, add `types: [opened, synchronize, reopened, edited]` > to re-check an edited pull request. ## Configuration diff --git a/action.yml b/action.yml index edfae12..09f8894 100644 --- a/action.yml +++ b/action.yml @@ -37,7 +37,7 @@ inputs: description: check pull request title following conventional commits required: false default: false - pr-body: + pr-body-ai-attribution: description: check the pull request description against the AI attribution rules (ai_attribution in cchk.toml) required: false default: false @@ -118,6 +118,6 @@ runs: JOB_SUMMARY: ${{ inputs.job-summary }} PR_COMMENTS: ${{ inputs.pr-comments }} PR_TITLE: ${{ inputs.pr-title }} - PR_BODY: ${{ inputs.pr-body }} + PR_BODY_AI_ATTRIBUTION: ${{ inputs.pr-body-ai-attribution }} AI_LABEL: ${{ inputs.ai-label }} GITHUB_TOKEN: ${{ github.token }} diff --git a/main.py b/main.py index 1f3bc36..5bb215d 100755 --- a/main.py +++ b/main.py @@ -87,7 +87,7 @@ def _reconfigure_io() -> None: JOB_SUMMARY_ENABLED = env_flag("JOB_SUMMARY") PR_COMMENTS_ENABLED = env_flag("PR_COMMENTS") PR_TITLE_ENABLED = env_flag("PR_TITLE") -PR_BODY_ENABLED = env_flag("PR_BODY") +PR_BODY_AI_ATTRIBUTION_ENABLED = env_flag("PR_BODY_AI_ATTRIBUTION") #: The label ``ai-label: true`` puts on a pull request that an AI tool wrote. DEFAULT_AI_LABEL = "ai-assisted" @@ -254,7 +254,7 @@ def log_env_vars(): "JOB_SUMMARY", "PR_COMMENTS", "PR_TITLE", - "PR_BODY", + "PR_BODY_AI_ATTRIBUTION", "AI_LABEL", ): value = os.getenv(name, "false") @@ -464,7 +464,7 @@ def get_pr_opener_tool() -> str | None: #: The AI tools found in the pull request description when it was read for -#: the label only (``ai-label`` without ``pr-body``), so it is no scope. +#: the label only (``ai-label`` without ``pr-body-ai-attribution``), so it is no scope. PR_BODY_AI_TOOLS: list[str] = [] @@ -789,7 +789,7 @@ def run_commit_check() -> tuple[int, list[ScopeResult]]: Checks are evaluated in order: 1. PR title (when ``pr-title: true`` and in a PR event) - 2. PR description, AI rules only (when ``pr-body: true`` and in a PR + 2. PR description, AI rules only (when ``pr-body-ai-attribution: true`` and in a PR event; with only ``ai-label`` set it is read for the label, and no scope is reported) 3. Individual PR commit messages (when ``message: true`` and in a PR event) @@ -807,13 +807,13 @@ def run_commit_check() -> tuple[int, list[ScopeResult]]: results.append(check_scope("PR title", ["--message"], input_text=pr_title)) # ---- 2. PR description ------------------------------------------------ - if (PR_BODY_ENABLED or ai_label_name()) and is_pr_event(): + if (PR_BODY_AI_ATTRIBUTION_ENABLED or ai_label_name()) and is_pr_event(): pr_body = get_pr_body() if pr_body: scope = check_scope( "PR description", ["--ai-attribution-only"], input_text=pr_body ) - if PR_BODY_ENABLED: + if PR_BODY_AI_ATTRIBUTION_ENABLED: results.append(scope) else: PR_BODY_AI_TOOLS[:] = scope.ai_tools diff --git a/main_test.py b/main_test.py index c1c0746..208b95e 100644 --- a/main_test.py +++ b/main_test.py @@ -153,7 +153,7 @@ def test_every_input_is_logged_as_a_debug_command(self): "::debug::JOB_SUMMARY=false", "::debug::PR_COMMENTS=false", "::debug::PR_TITLE=false", - "::debug::PR_BODY=false", + "::debug::PR_BODY_AI_ATTRIBUTION=false", "::debug::AI_LABEL=false", ], ) @@ -3699,7 +3699,7 @@ def _run(self, pr_body_enabled, ai_label, body="Adds a parser."): ) with ( patch("main.PR_TITLE_ENABLED", False), - patch("main.PR_BODY_ENABLED", pr_body_enabled), + patch("main.PR_BODY_AI_ATTRIBUTION_ENABLED", pr_body_enabled), patch.dict(os.environ, {"AI_LABEL": ai_label}), patch("main.MESSAGE_ENABLED", False), patch("main.BRANCH_ENABLED", False),