mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-24 06:11:06 +00:00
helper-scripts: add helper scripts used in release process
This commit is contained in:
parent
d9e5fd2682
commit
ed83016463
4
helper-scripts/README.md
Normal file
4
helper-scripts/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
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
|
27
helper-scripts/linkify-changelog.py
Executable file
27
helper-scripts/linkify-changelog.py
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
LINK_RE = re.compile(r"\[#(\d+)\]")
|
||||||
|
ISSUE_URL = "https://github.com/trezor/python-trezor/issues/"
|
||||||
|
|
||||||
|
CHANGELOG = os.path.dirname(__file__) + "/../CHANGELOG.md"
|
||||||
|
|
||||||
|
changelog_entries = set()
|
||||||
|
result_lines = []
|
||||||
|
|
||||||
|
with open(CHANGELOG, "r+") as changelog:
|
||||||
|
for line in changelog:
|
||||||
|
if ISSUE_URL in line:
|
||||||
|
break
|
||||||
|
for n in LINK_RE.findall(line):
|
||||||
|
changelog_entries.add(int(n))
|
||||||
|
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")
|
51
helper-scripts/relicence.py
Executable file
51
helper-scripts/relicence.py
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
LICENSE_NOTICE = """\
|
||||||
|
# This file is part of the Trezor project.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012-2018 SatoshiLabs and contributors
|
||||||
|
#
|
||||||
|
# This library is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
# as published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the License along with this library.
|
||||||
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXCLUDE_FILES = ["trezorlib/__init__.py", "trezorlib/_ed25519.py"]
|
||||||
|
|
||||||
|
|
||||||
|
def one_file(fp):
|
||||||
|
lines = list(fp)
|
||||||
|
new = lines[:]
|
||||||
|
while new and new[0][0] == "#":
|
||||||
|
new.pop(0)
|
||||||
|
|
||||||
|
while new and new[0].strip() == "":
|
||||||
|
new.pop(0)
|
||||||
|
|
||||||
|
data = "".join([LICENSE_NOTICE] + new)
|
||||||
|
|
||||||
|
fp.seek(0)
|
||||||
|
fp.write(data)
|
||||||
|
fp.truncate()
|
||||||
|
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
|
for fn in glob.glob("trezorlib/**/*.py", recursive=True):
|
||||||
|
if fn in EXCLUDE_FILES:
|
||||||
|
continue
|
||||||
|
statinfo = os.stat(fn)
|
||||||
|
if statinfo.st_size == 0:
|
||||||
|
continue
|
||||||
|
with open(fn, "r+") as fp:
|
||||||
|
one_file(fp)
|
Loading…
Reference in New Issue
Block a user