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