Skip to content

Commit 8ed9754

Browse files
authored
docs: added new script to build changelog (#381)
1 parent b33711a commit 8ed9754

3 files changed

Lines changed: 44 additions & 61 deletions

File tree

scripts/build_changelog.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from subprocess import run as _run, STDOUT, PIPE
2+
import re
3+
4+
5+
def run(cmd) -> str:
6+
return _run(cmd.split(" "), stdout=PIPE, stderr=STDOUT, encoding="utf8").stdout
7+
8+
9+
def process_line(s: str, repo: str) -> str:
10+
"""Generates links from commit and issue references (like 0c14d77, #123) to correct repo and such"""
11+
s = re.sub(r"#([0-9]+)", rf"[#\1](https://github.com/ActivityWatch/{repo}/issues/\1)", s)
12+
return s
13+
14+
15+
def commit_linkify(commitid: str, repo: str) -> str:
16+
return f"[`{commitid}`](https://github.com/ActivityWatch/{repo}/commit/{commitid})"
17+
18+
19+
def build():
20+
prev_release = run("git describe --tags --abbrev=0").strip()
21+
summary_bundle = run(f"git log {prev_release}...master --oneline --decorate")
22+
print("### activitywatch (bundle repo)")
23+
for line in summary_bundle.split("\n"):
24+
if line:
25+
commit = line.split(" ")[0]
26+
line = ' '.join(line.split(' ')[1:])
27+
commit_link = commit_linkify(commit, 'activitywatch')
28+
line = f" - {line} ({commit_link})"
29+
print(process_line(line, "activitywatch"))
30+
31+
summary_subrepos = run(f"git submodule summary {prev_release}")
32+
for s in summary_subrepos.split("\n\n"):
33+
lines = s.split("\n")
34+
header = lines[0]
35+
if header.strip():
36+
_, name, commitrange, count = header.split(" ")
37+
name = name.strip(".").strip("/")
38+
print(f"\n### {name} {commitrange}")
39+
commits = [process_line(" - " + l.strip(" ").strip(">").strip(" "), name) for l in lines[1:]]
40+
print("\n".join(commits))
41+
42+
43+
if __name__ == "__main__":
44+
build()

scripts/collect_stats.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

scripts/release_notes.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)