2018-12-04 14:44:10 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2019-05-29 16:33:45 +00:00
|
|
|
REPOS = {
|
|
|
|
"": "python-trezor",
|
|
|
|
"f": "trezor-firmware",
|
|
|
|
}
|
|
|
|
|
|
|
|
LINK_RE = re.compile(r"\[(f?)#(\d+)\]")
|
|
|
|
ISSUE_URL = "https://github.com/trezor/{repo}/issues/{issue}"
|
2018-12-04 14:44:10 +00:00
|
|
|
|
|
|
|
CHANGELOG = os.path.dirname(__file__) + "/../CHANGELOG.md"
|
|
|
|
|
|
|
|
changelog_entries = set()
|
2019-05-29 16:33:45 +00:00
|
|
|
links = set()
|
2018-12-04 14:44:10 +00:00
|
|
|
result_lines = []
|
|
|
|
|
|
|
|
with open(CHANGELOG, "r+") as changelog:
|
|
|
|
for line in changelog:
|
2019-05-29 16:33:45 +00:00
|
|
|
if LINK_RE.match(line): # line *starts with* issue identifier
|
2018-12-04 14:44:10 +00:00
|
|
|
break
|
2019-05-29 16:33:45 +00:00
|
|
|
for repo, issue in LINK_RE.findall(line):
|
|
|
|
changelog_entries.add((repo, int(issue)))
|
2018-12-04 14:44:10 +00:00
|
|
|
result_lines.append(line)
|
|
|
|
|
|
|
|
changelog.seek(0)
|
|
|
|
changelog.truncate(0)
|
|
|
|
for line in result_lines:
|
|
|
|
changelog.write(line)
|
2019-05-29 16:33:45 +00:00
|
|
|
for repo, issue in sorted(changelog_entries):
|
|
|
|
url = ISSUE_URL.format(repo=REPOS[repo], issue=issue)
|
|
|
|
changelog.write(f"[{repo}#{issue}]: {url}\n")
|