Skip to content

Commit aef8725

Browse files
committed
build: comment_on_fixes comments on pull requests too
1 parent 99e4937 commit aef8725

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

ci/comment_on_fixes.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,34 @@
1414
f"This is now released as part of [coverage {version}]" +
1515
f"(https://pypi.org/project/coverage/{version})."
1616
)
17-
print(f"Comment will be: {comment}")
17+
print(f"Comment will be:\n\n{comment}\n")
1818

1919
owner = "nedbat"
2020
repo = "coveragepy"
21-
for m in re.finditer(r"https://github.com/nedbat/coveragepy/(issues|pull)/(\d+)", latest["text"]):
21+
for m in re.finditer(rf"https://github.com/{owner}/{repo}/(issues|pull)/(\d+)", latest["text"]):
2222
kind, number = m.groups()
23+
do_comment = False
2324

2425
if kind == "issues":
2526
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}"
2627
issue_data = requests.get(url).json()
2728
if issue_data["state"] == "closed":
28-
print(f"Commenting on {m[0]}")
29-
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments"
30-
resp = requests.post(url, json={"body": comment})
31-
print(resp)
29+
do_comment = True
3230
else:
3331
print(f"Still open, comment manually: {m[0]}")
3432
else:
35-
print(f"You need to manually coment on {m[0]}")
33+
url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{number}"
34+
pull_data = requests.get(url).json()
35+
if pull_data["state"] == "closed":
36+
if pull_data["merged"]:
37+
do_comment = True
38+
else:
39+
print(f"Not merged, comment manually: {m[0]}")
40+
else:
41+
print(f"Still open, comment manually: {m[0]}")
42+
43+
if do_comment:
44+
print(f"Commenting on {m[0]}")
45+
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments"
46+
resp = requests.post(url, json={"body": comment})
47+
print(resp)

0 commit comments

Comments
 (0)