Skip to content

Commit 9049e4f

Browse files
committed
Update changelog generation.
1 parent 0dcbe0e commit 9049e4f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tasks.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,33 @@ def update_changelog(ctx: Context, version: str | None = None, dry_run: bool = F
151151
updating the actual change log file. Defaults to False.
152152
"""
153153
version = version or f"{datetime.now(tz=timezone.utc):%Y.%-m.%-d}"
154+
print(f"Getting all comments since {__version__}")
154155
output = subprocess.check_output(["git", "log", "--pretty=format:%s", f"v{__version__}..HEAD"])
155156
lines = []
156157
ignored_commits = []
157158
for line in output.decode("utf-8").strip().split("\n"):
158-
re_match = re.match(r"Merge pull request \#(\d+) from (.*)", line)
159+
re_match = re.match(r"(.*)\(\#(\d+)\)", line)
159160
if re_match and "materialsproject/dependabot/pip" not in line:
160-
pr_number = re_match[1]
161-
contributor, pr_name = re_match[2].split("/", 1)
161+
pr_number = re_match[2]
162+
pr_name = re_match[1]
162163
response = requests.get(
163164
f"https://api.github.com/repos/materialsproject/pymatgen/pulls/{pr_number}",
164165
timeout=60,
165166
)
166-
lines += [f"* PR #{pr_number} from @{contributor} {pr_name}"]
167+
lines += [f"* PR #{pr_number} {pr_name}"]
167168
json_resp = response.json()
169+
import pprint
170+
pprint.pprint(json_resp)
171+
lines += [f"* PR #{pr_number} {pr_name} by @{json_resp['user']['login']}"]
168172
if body := json_resp["body"]:
169173
for ll in map(str.strip, body.split("\n")):
170174
if ll in ("", "## Summary"):
171175
continue
172176
if ll.startswith(("## Checklist", "## TODO")):
173177
break
174178
lines += [f" {ll}"]
175-
ignored_commits += [line]
179+
else:
180+
ignored_commits += [line]
176181
with open("docs/CHANGES.md", encoding="utf-8") as file:
177182
contents = file.read()
178183
delim = "##"

0 commit comments

Comments
 (0)