| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,45 +40,41 @@ async def check_ci_status_and_approval(gh, sha, leave_comment=False): | |||
| 40 | 40 | "pending" not in all_ci_status | |
| 41 | 41 | and "continuous-integration/travis-ci/pr" in all_ci_context | |
| 42 | 42 | ): | |
| 43 | - async for ref in gh.getiter("/repos/miss-islington/cpython/git/refs/heads/"): | ||
| 44 | - if "backport-" in ref["ref"] and ref["object"]["sha"] == sha: | ||
| 45 | - backport_branch_name = ref["ref"].split("/")[-1] | ||
| 46 | - async for pr_response in gh.getiter( | ||
| 47 | - f"/repos/python/cpython/pulls?state=open&head=miss-islington:{backport_branch_name}" | ||
| 48 | - ): | ||
| 49 | - pr_number = pr_response["number"] | ||
| 50 | - normalized_pr_title = util.normalize_title( | ||
| 51 | - pr_response["title"], pr_response["body"] | ||
| 43 | + | ||
| 44 | + prs_for_commit = await gh.getitem(f'/search/issues?q=type:pr+repo:python/cpython+sha:{sha}') | ||
| 45 | + if prs_for_commit["total_count"] > 0: # there should only be one | ||
| 46 | + pr_for_commit = prs_for_commit["items"][0] | ||
| 47 | + pr_number = pr_for_commit["number"] | ||
| 48 | + normalized_pr_title = util.normalize_title( | ||
| 49 | + pr_for_commit["title"], pr_for_commit["body"] | ||
| 50 | + ) | ||
| 51 | + | ||
| 52 | + title_match = TITLE_RE.match(normalized_pr_title) | ||
| 53 | + if title_match: | ||
| 54 | + if leave_comment: | ||
| 55 | + original_pr_number = title_match.group("pr") | ||
| 56 | + original_pr_url = ( | ||
| 57 | + f"/repos/python/cpython/pulls/{original_pr_number}" | ||
| 52 | 58 | ) | |
| 59 | + original_pr_result = await gh.getitem(original_pr_url) | ||
| 60 | + pr_author = original_pr_result["user"]["login"] | ||
| 61 | + committer = original_pr_result["merged_by"]["login"] | ||
| 62 | + | ||
| 63 | + participants = util.get_participants(pr_author, committer) | ||
| 64 | + emoji = "✅" if result["state"] == "success" else "❌" | ||
| 53 | 65 | ||
| 54 | - title_match = TITLE_RE.match(normalized_pr_title) | ||
| 55 | - if title_match: | ||
| 56 | - | ||
| 57 | - if leave_comment: | ||
| 58 | - original_pr_number = title_match.group("pr") | ||
| 59 | - original_pr_url = ( | ||
| 60 | - f"/repos/python/cpython/pulls/{original_pr_number}" | ||
| 61 | - ) | ||
| 62 | - original_pr_result = await gh.getitem(original_pr_url) | ||
| 63 | - pr_author = original_pr_result["user"]["login"] | ||
| 64 | - committer = original_pr_result["merged_by"]["login"] | ||
| 65 | - | ||
| 66 | - participants = util.get_participants(pr_author, committer) | ||
| 67 | - emoji = "✅" if result["state"] == "success" else "❌" | ||
| 68 | - | ||
| 69 | - await util.leave_comment( | ||
| 70 | - gh, | ||
| 71 | - pr_number=pr_number, | ||
| 72 | - message=f"{participants}: Backport status check is done, and it's a {result['state']} {emoji} .", | ||
| 73 | - ) | ||
| 74 | - | ||
| 75 | - if result["state"] == "success": | ||
| 76 | - pr = await gh.getitem( | ||
| 77 | - f"/repos/python/cpython/pulls/{pr_number}" | ||
| 78 | - ) | ||
| 79 | - if util.pr_is_awaiting_merge(pr["labels"]): | ||
| 80 | - await merge_pr(gh, pr_number, sha) | ||
| 81 | - break | ||
| 66 | + await util.leave_comment( | ||
| 67 | + gh, | ||
| 68 | + pr_number=pr_number, | ||
| 69 | + message=f"{participants}: Backport status check is done, and it's a {result['state']} {emoji} .", | ||
| 70 | + ) | ||
| 71 | + | ||
| 72 | + if result["state"] == "success": | ||
| 73 | + pr = await gh.getitem( | ||
| 74 | + f"/repos/python/cpython/pulls/{pr_number}" | ||
| 75 | + ) | ||
| 76 | + if util.pr_is_awaiting_merge(pr["labels"]): | ||
| 77 | + await merge_pr(gh, pr_number, sha) | ||
| 82 | 78 | ||
| 83 | 79 | ||
| 84 | 80 | async def merge_pr(gh, pr_number, sha): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments