From a19a9a318a20ff74386535ab79adc7317a4e6dfb Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 2 Jul 2020 11:59:37 +0200 Subject: [PATCH] all: improve changelog formatting --- core/ChangeLog | 27 ++++++--- legacy/bootloader/ChangeLog | 4 +- legacy/firmware/ChangeLog | 7 ++- python/CHANGELOG.md | 36 ++++++------ python/helper-scripts/linkify-changelog.py | 34 ----------- tools/linkify-changelogs.py | 68 ++++++++++++++++++++++ 6 files changed, 112 insertions(+), 64 deletions(-) delete mode 100755 python/helper-scripts/linkify-changelog.py create mode 100755 tools/linkify-changelogs.py diff --git a/core/ChangeLog b/core/ChangeLog index b859b8e6bf..6e3a78fe51 100644 --- a/core/ChangeLog +++ b/core/ChangeLog @@ -9,15 +9,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). _Most likely to be released on July 1st._ ### Added -- Soft lock. #958 -- Auto lock. #1027 +- Soft lock. [#958] +- Auto lock. [#1027] - Dedicated `initialized` field in storage. -- Support EXTERNAL transaction inputs with a SLIP-0019 proof of ownership #1052 -- Support pre-signed EXTERNAL transaction inputs +- Support EXTERNAL transaction inputs with a SLIP-0019 proof of ownership. [#1052] +- Support pre-signed EXTERNAL transaction inputs. ### Changed - `Features.pin_cached` renamed to `unlocked`. -- Forbid all settings if the device is not yet initialized. #1056 +- Forbid all settings if the device is not yet initialized. [#1056] ### Deprecated - Deprecate `Overwintered` field in `SignTx` and `TxAck`. @@ -26,10 +26,10 @@ _Most likely to be released on July 1st._ - Generated protobuf classes now do not contain deprecated fields. ### Fixed -- Fix cancel icon in PIN dialog. #1042 -- Fix repaint bug in QR code rendering. #1067 -- Fix QR code overlapping in Monero address. monero-gui #2960 -- Re-introduce ability to spend pre-Overwinter UTXO on Zcash-like coins. #1030 +- Fix cancel icon in PIN dialog. [#1042] +- Fix repaint bug in QR code rendering. [#1067] +- Fix QR code overlapping in Monero address. monero-gui#2960, [#1074] +- Re-introduce ability to spend pre-Overwinter UTXO on Zcash-like coins. [#1030] ### Security @@ -159,3 +159,12 @@ Version 2.0.6 [Mar 2018] Version 2.0.5 [Mar 2018] * first public release + +[#958]: https://github.com/trezor/trezor-firmware/issues/958 +[#1027]: https://github.com/trezor/trezor-firmware/issues/1027 +[#1030]: https://github.com/trezor/trezor-firmware/issues/1030 +[#1042]: https://github.com/trezor/trezor-firmware/issues/1042 +[#1052]: https://github.com/trezor/trezor-firmware/issues/1052 +[#1056]: https://github.com/trezor/trezor-firmware/issues/1056 +[#1067]: https://github.com/trezor/trezor-firmware/issues/1067 +[#1074]: https://github.com/trezor/trezor-firmware/issues/1074 diff --git a/legacy/bootloader/ChangeLog b/legacy/bootloader/ChangeLog index a8645444b9..8ac6f730c8 100644 --- a/legacy/bootloader/ChangeLog +++ b/legacy/bootloader/ChangeLog @@ -8,12 +8,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +### Changed +- Use Trezor instead of TREZOR + ### Deprecated ### Removed ### Fixed -- Use Trezor instead of TREZOR ### Security diff --git a/legacy/firmware/ChangeLog b/legacy/firmware/ChangeLog index 64e707e805..d0ff1c45de 100644 --- a/legacy/firmware/ChangeLog +++ b/legacy/firmware/ChangeLog @@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added -- Set initialized in storage to false if no mnemonic is present. #965 +- Set initialized in storage to false if no mnemonic is present. [#965] ### Changed - `Features.pin_cached` renamed to `unlocked`, and it is now `true` even if PIN is not set. @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Removed ### Fixed -- Re-introduce ability to spend pre-Overwinter UTXO on Zcash-like coins. #1030 +- Re-introduce ability to spend pre-Overwinter UTXO on Zcash-like coins. [#1030] ### Security @@ -203,3 +203,6 @@ Version 1.1.0 [Jun 2014] Version 1.0.0 [Apr 2014] * Added support for streaming of transactions into the device * Removed all current limits on size of signed transaction + +[#965]: https://github.com/trezor/trezor-firmware/issues/965 +[#1030]: https://github.com/trezor/trezor-firmware/issues/1030 diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 751661a447..6112f77ad3 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -369,6 +369,24 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/ - gradually dropping Python 2 compatibility (pypi package will now be marked as Python 3 only) +[f#41]: https://github.com/trezor/trezor-firmware/issues/41 +[f#87]: https://github.com/trezor/trezor-firmware/issues/87 +[f#116]: https://github.com/trezor/trezor-firmware/issues/116 +[f#117]: https://github.com/trezor/trezor-firmware/issues/117 +[f#224]: https://github.com/trezor/trezor-firmware/issues/224 +[f#226]: https://github.com/trezor/trezor-firmware/issues/226 +[f#363]: https://github.com/trezor/trezor-firmware/issues/363 +[f#411]: https://github.com/trezor/trezor-firmware/issues/411 +[f#420]: https://github.com/trezor/trezor-firmware/issues/420 +[f#445]: https://github.com/trezor/trezor-firmware/issues/445 +[f#510]: https://github.com/trezor/trezor-firmware/issues/510 +[f#525]: https://github.com/trezor/trezor-firmware/issues/525 +[f#666]: https://github.com/trezor/trezor-firmware/issues/666 +[f#680]: https://github.com/trezor/trezor-firmware/issues/680 +[f#681]: https://github.com/trezor/trezor-firmware/issues/681 +[f#778]: https://github.com/trezor/trezor-firmware/issues/778 +[f#823]: https://github.com/trezor/trezor-firmware/issues/823 +[f#1082]: https://github.com/trezor/trezor-firmware/issues/1082 [#94]: https://github.com/trezor/python-trezor/issues/94 [#167]: https://github.com/trezor/python-trezor/issues/167 [#169]: https://github.com/trezor/python-trezor/issues/169 @@ -412,21 +430,3 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/ [#349]: https://github.com/trezor/python-trezor/issues/349 [#351]: https://github.com/trezor/python-trezor/issues/351 [#352]: https://github.com/trezor/python-trezor/issues/352 -[f#41]: https://github.com/trezor/trezor-firmware/issues/41 -[f#87]: https://github.com/trezor/trezor-firmware/issues/87 -[f#116]: https://github.com/trezor/trezor-firmware/issues/116 -[f#117]: https://github.com/trezor/trezor-firmware/issues/117 -[f#224]: https://github.com/trezor/trezor-firmware/issues/224 -[f#226]: https://github.com/trezor/trezor-firmware/issues/226 -[f#363]: https://github.com/trezor/trezor-firmware/issues/363 -[f#411]: https://github.com/trezor/trezor-firmware/issues/411 -[f#420]: https://github.com/trezor/trezor-firmware/issues/420 -[f#445]: https://github.com/trezor/trezor-firmware/issues/445 -[f#510]: https://github.com/trezor/trezor-firmware/issues/510 -[f#525]: https://github.com/trezor/trezor-firmware/issues/525 -[f#666]: https://github.com/trezor/trezor-firmware/issues/666 -[f#680]: https://github.com/trezor/trezor-firmware/issues/680 -[f#681]: https://github.com/trezor/trezor-firmware/issues/681 -[f#778]: https://github.com/trezor/trezor-firmware/issues/778 -[f#823]: https://github.com/trezor/trezor-firmware/issues/823 -[f#1082]: https://github.com/trezor/trezor-firmware/issues/1082 diff --git a/python/helper-scripts/linkify-changelog.py b/python/helper-scripts/linkify-changelog.py deleted file mode 100755 index f4d29e6ea6..0000000000 --- a/python/helper-scripts/linkify-changelog.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 - -import os -import re - -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 LINK_RE.match(line): # line *starts with* issue identifier - break - 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 repo, issue in sorted(changelog_entries): - url = ISSUE_URL.format(repo=REPOS[repo], issue=issue) - changelog.write(f"[{repo}#{issue}]: {url}\n") diff --git a/tools/linkify-changelogs.py b/tools/linkify-changelogs.py new file mode 100755 index 0000000000..02c8e8e87c --- /dev/null +++ b/tools/linkify-changelogs.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +import os +from pathlib import Path +import re + +import click + +LINK_RE = re.compile(r"\[#(\d+)\]") +ISSUE_URL = "https://github.com/trezor/trezor-firmware/issues/{issue}" + +ROOT = Path(__file__).parent.resolve().parent + +DEFAULT_CHANGELOGS = ( # TODO replace with a wildcard? + ROOT / "core" / "ChangeLog", + ROOT / "legacy" / "firmware" / "ChangeLog", + ROOT / "legacy" / "bootloader" / "ChangeLog", + ROOT / "python" / "CHANGELOG.md", +) + + +def process_changelog(changelog_file): + links = {} + result_lines = [] + + with open(changelog_file, "r+") as changelog: + for line in changelog: + m = LINK_RE.match(line) + if m: # line *starts with* issue identifier + # keep existing links as-is + links[int(m[1])] = line.replace(m[0] + ": ", "").strip() + else: + for issue in LINK_RE.findall(line): + links[int(issue)] = ISSUE_URL.format(issue=issue) + result_lines.append(line) + + changelog.seek(0) + changelog.truncate(0) + for line in result_lines: + changelog.write(line) + for marker, url in sorted(links.items()): + changelog.write(f"[#{marker}]: {url}\n") + + +@click.command() +@click.argument( + "changelogs", + nargs=-1, + type=click.Path(exists=True, dir_okay=False, writable=True), +) +def cli(changelogs): + """Linkify changelog. + + Find all occurences of "[#123]" in text, and add a Markdown link to the referenced + issue. + + If no arguments are provided, runs on all known changelogs. + """ + if not changelogs: + changelogs = DEFAULT_CHANGELOGS + + for changelog in changelogs: + click.echo(f"Linkifying {changelog}...") + process_changelog(changelog) + + +if __name__ == "__main__": + cli()