|
14 | 14 | f"This is now released as part of [coverage {version}]" +
|
15 | 15 | f"(https://pypi.org/project/coverage/{version})."
|
16 | 16 | )
|
17 |
| -print(f"Comment will be: {comment}") |
| 17 | +print(f"Comment will be:\n\n{comment}\n") |
18 | 18 |
|
19 | 19 | owner = "nedbat"
|
20 | 20 | 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"]): |
22 | 22 | kind, number = m.groups()
|
| 23 | + do_comment = False |
23 | 24 |
|
24 | 25 | if kind == "issues":
|
25 | 26 | url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}"
|
26 | 27 | issue_data = requests.get(url).json()
|
27 | 28 | 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 |
32 | 30 | else:
|
33 | 31 | print(f"Still open, comment manually: {m[0]}")
|
34 | 32 | 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