diff options
Diffstat (limited to 'ci')
| -rw-r--r-- | ci/comment_on_fixes.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ci/comment_on_fixes.py b/ci/comment_on_fixes.py index b76a6cda..f36cba93 100644 --- a/ci/comment_on_fixes.py +++ b/ci/comment_on_fixes.py @@ -2,7 +2,6 @@ import json import re -import time import requests @@ -23,10 +22,14 @@ for m in re.finditer(r"https://github.com/nedbat/coveragepy/(issues|pull)/(\d+)" kind, number = m.groups() if kind == "issues": - print(f"Commenting on {m[0]}") - url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments" - resp = requests.post(url, json={"body": comment}) - print(resp) - time.sleep(1) + url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}" + issue_data = requests.get(url).json() + if issue_data["state"] == "closed": + print(f"Commenting on {m[0]}") + url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments" + resp = requests.post(url, json={"body": comment}) + print(resp) + else: + print(f"Still open, comment manually: {m[0]}") else: print(f"You need to manually coment on {m[0]}") |
