forked from Mariatta/check_python_cla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.py
More file actions
33 lines (25 loc) · 1.11 KB
/
Copy pathgithub.py
File metadata and controls
33 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
SEARCH_PR_URL = '/search/issues?q=type:pr+author:{gh_username}+state:open+org:python+label:"CLA not signed"&sort=created&order=asc'
async def get_user_pending_pull_requests(gh, gh_username):
"""Retrieve open prs for the GitHub user where there is `CLA not signed` label."""
result = await gh.getitem(
SEARCH_PR_URL.format(gh_username=gh_username),
accept="application/vnd.github.symmetra-preview+json",
)
return result["items"]
async def update_pr_cla_status(gh, pr_data):
"""Remove the `CLA not signed` label from the PR."""
pr_labels = [
label["name"]
for label in pr_data["labels"]
if label["name"] != "CLA not signed"
]
await gh.patch(pr_data["url"], data={"labels": pr_labels})
async def get_and_update_pending_prs(gh, gh_username):
"""Retrieve open PRs, and remove the `CLA not signed` label from the PRs."""
pending_prs = await get_user_pending_pull_requests(gh, gh_username)
for pending_pr in pending_prs:
await update_pr_cla_status(gh, pending_pr)
if len(pending_prs) > 0:
return pending_prs
else:
return []