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
10 changes: 9 additions & 1 deletion scripts/pr_quality/check_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions scripts/pr_quality/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`).",
)
9 changes: 9 additions & 0 deletions scripts/pr_quality/tests/test_check_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading