diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-06-02 10:57:53 -0400 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-06-02 11:43:31 -0400 |
| commit | 672cfaa53c72dd67fb54ecbdd904ea364d2951c4 (patch) | |
| tree | dc62957182f8b12c8d54bfee3ee34fd73ebe9924 /scripts | |
| parent | 48e0a64e6491b464249086d6052a00c8d2be418e (diff) | |
Made PR quality check require tickets for new contributors.
Agents are already abusing the exception for small pull requests
by mixing in unrelated typo fixes with their code changes for
unreviewed tickets and removing mention of said ticket.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/pr_quality/check_pr.py | 10 | ||||
| -rw-r--r-- | scripts/pr_quality/errors.py | 5 | ||||
| -rw-r--r-- | scripts/pr_quality/tests/test_check_pr.py | 9 |
3 files changed, 21 insertions, 3 deletions
diff --git a/scripts/pr_quality/check_pr.py b/scripts/pr_quality/check_pr.py index e1991e46d3..2cf225a27a 100644 --- a/scripts/pr_quality/check_pr.py +++ b/scripts/pr_quality/check_pr.py @@ -470,10 +470,18 @@ def main( pr_number, ) return + if commit_count == 0: + logger.info( + "PR #%s author has no commits -- setting size threshold to 0.", + pr_number, + ) + threshold = 0 + else: + threshold = LARGE_PR_THRESHOLD pr_title_result = SKIPPED total_changes = get_pr_total_changes(pr_number, repo, token) - ticket_result = check_trac_ticket(pr_body, total_changes) + ticket_result = check_trac_ticket(pr_body, total_changes, threshold) ticket_status_result = SKIPPED ticket_has_patch_result = SKIPPED ticket_id = extract_ticket_id(pr_body) if ticket_result is None else None diff --git a/scripts/pr_quality/errors.py b/scripts/pr_quality/errors.py index cd305868ac..cd41612da3 100644 --- a/scripts/pr_quality/errors.py +++ b/scripts/pr_quality/errors.py @@ -154,6 +154,7 @@ MISSING_TRAC_TICKET = ( "Patches submitted against unreviewed tickets are unlikely to be merged.\n" "3. Edit the **Trac ticket number** section of your PR description to include " "the ticket in the format `ticket-NNNNN` (e.g. `ticket-36991`).\n\n" - "For PRs with fewer than {threshold} lines changed (additions + deletions), you " - "may write `N/A` in the ticket field instead (e.g. `N/A - typo fix`).", + "Unless this is your first contribution, for PRs with fewer than {threshold} lines " + "changed (additions + deletions), you may write `N/A` in the ticket field instead " + "(e.g. `N/A - typo fix`).", ) diff --git a/scripts/pr_quality/tests/test_check_pr.py b/scripts/pr_quality/tests/test_check_pr.py index 30bfa26512..0aff15ca10 100644 --- a/scripts/pr_quality/tests/test_check_pr.py +++ b/scripts/pr_quality/tests/test_check_pr.py @@ -770,6 +770,15 @@ class TestIntegration(BaseTestCase): self.assertIsNone(result) mock_gh.assert_not_called() + def test_new_contributor_cannot_omit_ticket(self): + body = make_pr_body(ticket="", checked_items=0) + _, mock_summary, _ = self.call_main(pr_body=body, commit_count=0) + _, results, _ = mock_summary.call_args.args + result_map = {name: result for name, result, _ in results} + self.assertEqual( + result_map["Trac ticket referenced"].title, check_pr.MISSING_TRAC_TICKET[0] + ) + def test_fully_valid_pr_no_comment_posted(self): result, _, mock_gh = self.call_main( pr_body=VALID_PR_BODY, pr_title=VALID_PR_TITLE |
