1
0
mirror of git://jb55.com/damus synced 2024-09-29 16:30:44 +00:00

Add author to changelog tool

This commit is contained in:
William Casarin 2022-12-28 13:32:17 -08:00
parent 3405742350
commit 54cfdb8dcc

View File

@ -24,7 +24,7 @@ sections = [
repo = 'damus-io/damus'
Entry = namedtuple("Entry", ["commit", "pullreq", "content", "section"])
Entry = namedtuple("Entry", ["commit", "pullreq", "content", "section", "author"])
Link = namedtuple("Link", ["ref", "content", "url"])
@ -46,14 +46,20 @@ def get_log_entries(commitrange):
commit = None
logs = git("log {commitrange}".format(commitrange=commitrange))
entries = []
author = ""
for l in logs.split('\n'):
m = re.match(r'^commit ([A-Fa-f0-9]{40})$', l)
a = re.match(r'^Author: ([^<]+)<.*$', l)
if m:
commit = m.group(1)
if a:
author = "(" + a.group(1)[:-1] + ")"
m = re.match(
r'^\s+Changelog-({}): (.*)$'.format("|".join(sections)), l, re.IGNORECASE)
if not m:
continue
@ -73,7 +79,7 @@ def get_log_entries(commitrange):
# pullreq = None
pullreq = None
e = Entry(commit, pullreq, m.group(2), m.group(1).lower())
e = Entry(commit, pullreq, m.group(2), m.group(1).lower(), author)
entries.append(e)
return entries
@ -112,9 +118,9 @@ def commit_date(commitsha):
template = Template("""<%def name="group(entries)">
% for e in entries:
% if e.pullreq is not None:
- ${e.content} ([#${e.pullreq}])
- ${e.content} ([#${e.pullreq}])
% else:
- ${e.content}
- ${e.content} ${e.author}
% endif
% endfor