|
21 | 21 | print(f"Comment will be:\n\n{comment}\n")
|
22 | 22 |
|
23 | 23 | repo_owner = sys.argv[1]
|
24 |
| -for m in re.finditer(fr"https://github.com/{repo_owner}/(issues|pull)/(\d+)", latest["text"]): |
25 |
| - kind, number = m.groups() |
| 24 | +url_matches = re.finditer(fr"https://github.com/{repo_owner}/(issues|pull)/(\d+)", latest["text"]) |
| 25 | +urls = set((m[0], m[1], m[2]) for m in url_matches) |
| 26 | + |
| 27 | +for url, kind, number in urls: |
26 | 28 | do_comment = False
|
27 | 29 |
|
28 | 30 | if kind == "issues":
|
|
31 | 33 | if issue_data["state"] == "closed":
|
32 | 34 | do_comment = True
|
33 | 35 | else:
|
34 |
| - print(f"Still open, comment manually: {m[0]}") |
| 36 | + print(f"Still open, comment manually: {url}") |
35 | 37 | else:
|
36 | 38 | url = f"https://api.github.com/repos/{repo_owner}/pulls/{number}"
|
37 | 39 | pull_data = get_session().get(url).json()
|
38 | 40 | if pull_data["state"] == "closed":
|
39 | 41 | if pull_data["merged"]:
|
40 | 42 | do_comment = True
|
41 | 43 | else:
|
42 |
| - print(f"Not merged, comment manually: {m[0]}") |
| 44 | + print(f"Not merged, comment manually: {url}") |
43 | 45 | else:
|
44 |
| - print(f"Still open, comment manually: {m[0]}") |
| 46 | + print(f"Still open, comment manually: {url}") |
45 | 47 |
|
46 | 48 | if do_comment:
|
47 |
| - print(f"Commenting on {m[0]}") |
| 49 | + print(f"Commenting on {url}") |
48 | 50 | url = f"https://api.github.com/repos/{repo_owner}/issues/{number}/comments"
|
49 | 51 | resp = get_session().post(url, json={"body": comment})
|
50 | 52 | print(resp)
|
0 commit comments