From bd1f3a1995a99fee0734a2d357b177bea6a2753a Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 21 Jun 2022 07:48:37 -0700 Subject: [PATCH] dev: changelog script fixes Signed-off-by: William Casarin --- devtools/changelog.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/devtools/changelog.py b/devtools/changelog.py index 116bf60..0182634 100755 --- a/devtools/changelog.py +++ b/devtools/changelog.py @@ -67,7 +67,7 @@ def get_log_entries(commitrange): url = 'https://api.github.com/repos/{repo}/commits/{commit}/pulls'.format(repo=repo, commit=commit) content = requests.get(url, headers=headers).json() - if content.get(0) is not None: + if content and content.get(0) is not None: pullreq = content[0]['number'] else: pullreq = None @@ -81,11 +81,12 @@ def get_log_entries(commitrange): def linkify(entries): links = [] for e in entries: - links.append(Link( - ref='#{}'.format(e.pullreq), - content=e.content, - url="https://github.com/{repo}/pull/{pullreq}".format(repo=repo, pullreq=e.pullreq) - )) + if e.pullreq is not None: + links.append(Link( + ref='#{}'.format(e.pullreq), + content=e.content, + url="https://github.com/{repo}/pull/{pullreq}".format(repo=repo, pullreq=e.pullreq) + )) return list(set(links)) @@ -118,12 +119,9 @@ template = Template("""<%def name="group(entries)"> <%def name="group_links(entries)"> % for e in entries: -[${e.pullreq}]: https://github.com/{repo}/pull/${e.pullreq} +[${e.pullreq}]: https://github.com/${repo}/pull/${e.pullreq} % endfor - ${h2} [${version}] - ${date.strftime("%Y-%m-%d")} @@ -135,7 +133,7 @@ ${group(groups[section]) | trim} % for l in links: [${l.ref}]: ${l.url} % endfor -[${version}]: https://github.com/{repo}/releases/tag/v${version}""") +[${version}]: https://github.com/${repo}/releases/tag/v${version}""") if __name__ == "__main__":