Skip to content

Commit dea11bf

Browse files
committed
changelog.py: fix release dates and tag commits
1 parent d1a4566 commit dea11bf

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

changelog.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@
2626
shell=True,
2727
).decode('utf8').split('\n')
2828

29-
now = datetime.now()
30-
3129
tags = {}
3230
tag_commits = []
3331
for line in git_log:
3432
parts = line.split()
3533
if len(parts) == 1:
3634
tag_commits.append(parts[0])
37-
elif len(parts) > 1 and parts[1] == 'tag:':
38-
tags[tag] = tag_commits
39-
tag = parts[2]
40-
tag_commits = [parts[0]]
35+
continue
36+
37+
for i, part in enumerate(parts):
38+
if part == 'tag:':
39+
tags[tag] = tag_commits
40+
tag = parts[i + 1].strip(',')
41+
tag_commits = [parts[0]]
42+
43+
# add remaining commits to last seen tag
44+
tags[tag] = tag_commits
4145

4246
lines = []
4347
for tag, shas in tags.items():
@@ -51,7 +55,11 @@
5155
shell=True,
5256
).decode('utf8').split('\n')[0].split('--sep--')
5357
if description.startswith('Release '):
54-
lines.append(f' {now.year}-{now.month}-{now.day} {description}')
58+
date = subprocess.check_output(
59+
f"git log --format='%as' -n1 {sha}",
60+
shell=True,
61+
).decode('utf8').strip()
62+
lines.append(f' {date} {description}')
5563
continue
5664
try:
5765
commit = repo.get_commit(sha)

0 commit comments

Comments
 (0)