diff --git a/scripts/pr_quality/check_pr.py b/scripts/pr_quality/check_pr.py index e1991e46d361..2cf225a27aac 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 cd305868ac37..cd41612da341 100644 --- a/scripts/pr_quality/errors.py +++ b/scripts/pr_quality/errors.py @@ -154,6 +154,7 @@ def as_details(self, level=LEVEL_ERROR): "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 30bfa26512aa..0aff15ca109b 100644 --- a/scripts/pr_quality/tests/test_check_pr.py +++ b/scripts/pr_quality/tests/test_check_pr.py @@ -770,6 +770,15 @@ def test_established_author_skips_all_checks(self): 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