python/changelog: update changelog generator

pull/200/head
matejcik 5 years ago
parent af2d35250a
commit 8d393b8925

@ -2,3 +2,5 @@ These scripts automate some tasks related to release process.
* __`relicence.py`__ rewrites licence headers in all non-empty Python files
* __`linkify-changelog.py`__ generates Markdown links to github issues/PRs in changelog
* __`bump-required-fw-versions.py`__ downloads latest firmware versions and updates trezorlib requirements
* __`build-coins-json.sh`__ generates `coins.json`, or checks if it is up-to-date

@ -3,25 +3,32 @@
import os
import re
LINK_RE = re.compile(r"\[#(\d+)\]")
ISSUE_URL = "https://github.com/trezor/python-trezor/issues/"
REPOS = {
"": "python-trezor",
"f": "trezor-firmware",
}
LINK_RE = re.compile(r"\[(f?)#(\d+)\]")
ISSUE_URL = "https://github.com/trezor/{repo}/issues/{issue}"
CHANGELOG = os.path.dirname(__file__) + "/../CHANGELOG.md"
changelog_entries = set()
links = set()
result_lines = []
with open(CHANGELOG, "r+") as changelog:
for line in changelog:
if ISSUE_URL in line:
if LINK_RE.match(line): # line *starts with* issue identifier
break
for n in LINK_RE.findall(line):
changelog_entries.add(int(n))
for repo, issue in LINK_RE.findall(line):
changelog_entries.add((repo, int(issue)))
result_lines.append(line)
changelog.seek(0)
changelog.truncate(0)
for line in result_lines:
changelog.write(line)
for issue in sorted(changelog_entries):
changelog.write(f"[#{issue}]: {ISSUE_URL}{issue}\n")
for repo, issue in sorted(changelog_entries):
url = ISSUE_URL.format(repo=REPOS[repo], issue=issue)
changelog.write(f"[{repo}#{issue}]: {url}\n")

Loading…
Cancel
Save