Skip to content

Commit f3b269c

Browse files
committed
build: only comment once on an issue mentioned twice
1 parent 2649c5c commit f3b269c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ci/comment_on_fixes.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
print(f"Comment will be:\n\n{comment}\n")
2222

2323
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:
2628
do_comment = False
2729

2830
if kind == "issues":
@@ -31,20 +33,20 @@
3133
if issue_data["state"] == "closed":
3234
do_comment = True
3335
else:
34-
print(f"Still open, comment manually: {m[0]}")
36+
print(f"Still open, comment manually: {url}")
3537
else:
3638
url = f"https://api.github.com/repos/{repo_owner}/pulls/{number}"
3739
pull_data = get_session().get(url).json()
3840
if pull_data["state"] == "closed":
3941
if pull_data["merged"]:
4042
do_comment = True
4143
else:
42-
print(f"Not merged, comment manually: {m[0]}")
44+
print(f"Not merged, comment manually: {url}")
4345
else:
44-
print(f"Still open, comment manually: {m[0]}")
46+
print(f"Still open, comment manually: {url}")
4547

4648
if do_comment:
47-
print(f"Commenting on {m[0]}")
49+
print(f"Commenting on {url}")
4850
url = f"https://api.github.com/repos/{repo_owner}/issues/{number}/comments"
4951
resp = get_session().post(url, json={"body": comment})
5052
print(resp)

0 commit comments

Comments
 (0)