From 8d393b892572d7c4c1b8e14cee10ecc304510b0a Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 29 May 2019 18:33:45 +0200 Subject: [PATCH] python/changelog: update changelog generator --- python/helper-scripts/README.md | 2 ++ python/helper-scripts/linkify-changelog.py | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/python/helper-scripts/README.md b/python/helper-scripts/README.md index 5dadfcbe74..7455dee409 100644 --- a/python/helper-scripts/README.md +++ b/python/helper-scripts/README.md @@ -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 diff --git a/python/helper-scripts/linkify-changelog.py b/python/helper-scripts/linkify-changelog.py index 66b99b5b6e..f4d29e6ea6 100755 --- a/python/helper-scripts/linkify-changelog.py +++ b/python/helper-scripts/linkify-changelog.py @@ -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")