summaryrefslogtreecommitdiff
path: root/ci/comment_on_fixes.py
diff options
context:
space:
mode:
Diffstat (limited to 'ci/comment_on_fixes.py')
-rw-r--r--ci/comment_on_fixes.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/ci/comment_on_fixes.py b/ci/comment_on_fixes.py
new file mode 100644
index 00000000..b76a6cda
--- /dev/null
+++ b/ci/comment_on_fixes.py
@@ -0,0 +1,32 @@
+"""Add a release comment to all the issues mentioned in the latest release."""
+
+import json
+import re
+import time
+
+import requests
+
+with open("tmp/relnotes.json") as frn:
+ relnotes = json.load(frn)
+
+latest = relnotes[0]
+version = latest["version"]
+comment = (
+ f"This is now released as part of [coverage {version}]" +
+ f"(https://pypi.org/project/coverage/{version})."
+ )
+print(f"Comment will be: {comment}")
+
+owner = "nedbat"
+repo = "coveragepy"
+for m in re.finditer(r"https://github.com/nedbat/coveragepy/(issues|pull)/(\d+)", latest["text"]):
+ 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)
+ else:
+ print(f"You need to manually coment on {m[0]}")