MCPcopy
hub / github.com/django/django / main

Function main

scripts/pr_quality/check_pr.py:439–569  ·  view source on GitHub ↗
(
    repo,
    token,
    pr_author,
    pr_body,
    pr_number,
    pr_title="",
    pr_created_at=None,
    autoclose=True,
    summary_file=None,
    gha_formatter=False,
)

Source from the content-addressed store, hash-verified

437
438
439def main(
440 repo,
441 token,
442 pr_author,
443 pr_body,
444 pr_number,
445 pr_title="",
446 pr_created_at=None,
447 autoclose=True,
448 summary_file=None,
449 gha_formatter=False,
450):
451 setup_logging(logger, gha_formatter)
452
453 created_date = (
454 datetime.fromisoformat(pr_created_at).date() if pr_created_at else None
455 )
456 if created_date is not None and created_date <= PR_TEMPLATE_DATE:
457 logger.info(
458 "PR #%s is older than PR template (%s) -- skipping all checks.",
459 pr_number,
460 PR_TEMPLATE_DATE,
461 )
462 return
463
464 commit_count = get_recent_commit_count(
465 pr_author, repo, token, since_days=365 * 3, max_count=5
466 )
467 if commit_count >= 5:
468 logger.info(
469 "PR #%s author is an established contributor -- skipping all checks.",
470 pr_number,
471 )
472 return
473
474 pr_title_result = SKIPPED
475 total_changes = get_pr_total_changes(pr_number, repo, token)
476 ticket_result = check_trac_ticket(pr_body, total_changes)
477 ticket_status_result = SKIPPED
478 ticket_has_patch_result = SKIPPED
479 ticket_id = extract_ticket_id(pr_body) if ticket_result is None else None
480 if ticket_id:
481 pr_title_result = check_pr_title_has_ticket(pr_title, ticket_id)
482 ticket_data = fetch_trac_ticket(ticket_id)
483 ticket_status_result = check_trac_status(ticket_id, ticket_data)
484 if ticket_status_result is None:
485 # Polling is disabled (poll_timeout=0): has_patch is a non-fatal
486 # warning, and contributors often update Trac after reviewing their
487 # PR, making any fixed polling window unreliable.
488 ticket_has_patch_result = check_trac_has_patch(
489 ticket_id, ticket_data, poll_timeout=0
490 )
491 else:
492 logger.info("Trac ticket is not Accepted -- skipping has_patch check.")
493 else:
494 logger.info("No Trac ticket -- skipping status and has_patch checks.")
495
496 if created_date is not None and created_date <= AI_DISCLOSURE_DATE:

Callers 1

check_pr.pyFile · 0.70

Calls 15

setup_loggingFunction · 0.85
get_recent_commit_countFunction · 0.85
get_pr_total_changesFunction · 0.85
check_trac_ticketFunction · 0.85
extract_ticket_idFunction · 0.85
fetch_trac_ticketFunction · 0.85
check_trac_statusFunction · 0.85
check_trac_has_patchFunction · 0.85
check_ai_disclosureFunction · 0.85
check_branch_descriptionFunction · 0.85
check_checklistFunction · 0.85

Tested by

no test coverage detected