Skip to content

Commit 77b39b5

Browse files
committed
fix: fixed generation of changelog for subsubmodules
1 parent 7e6acf2 commit 77b39b5

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

scripts/build_changelog.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ def commit_linkify(commitid: str, repo: str) -> str:
8989
return f"[`{commitid}`](https://github.com/ActivityWatch/{repo}/commit/{commitid})"
9090

9191

92-
def summary_repo(
93-
path: str, commitrange: str, filter_types: List[str]
94-
) -> Tuple[str, List[str]]:
92+
def summary_repo(path: str, commitrange: str, filter_types: List[str]) -> str:
93+
if commitrange.endswith("0000000"):
94+
# Happens when a submodule has been removed
95+
return ""
9596
dirname = run("bash -c 'basename $(pwd)'", cwd=path).strip()
96-
out = f"## {dirname}"
97+
out = f"\n## {dirname}"
9798

9899
feats = ""
99100
fixes = ""
@@ -117,47 +118,45 @@ def summary_repo(
117118
for name, entries in (("✨ Features", feats), ("🐛 Fixes", fixes), ("🔨 Misc", misc)):
118119
if entries:
119120
if "Misc" in name:
120-
header = f"\n\n<details><summary><b>{name}</b></summary>\n<p>\n\n"
121+
header = f"\n\n<details><summary><b>{name}</b></summary>\n<p>\n"
121122
else:
122123
header = f"\n\n#### {name}"
123124
out += header
124125
out += entries
125126
if "Misc" in name:
126127
out += "\n\n</p></details>"
127128

128-
submodules = []
129-
output = run("git submodule foreach 'basename $(pwd)'")
130-
for line in output.split("\n"):
131-
if not line or line.startswith("Entering"):
132-
continue
133-
submodules.append(line)
134-
135-
return out, submodules
136-
137-
138-
def build(filter_types=["build", "ci", "tests"]):
139-
prev_release = run("git describe --tags --abbrev=0").strip()
140-
output, submodules = summary_repo(
141-
".", commitrange=f"{prev_release}...master", filter_types=filter_types
142-
)
143-
print(output)
144-
145-
# TODO: Include subsubmodules (like aw-webui)
146-
# TODO: Include commits from merges (exclude merge commits themselves?)
129+
# NOTE: For now, these TODOs can be manually fixed for each changelog.
130+
# TODO: Fix issue where subsubmodules can appear twice (like aw-webui)
147131
# TODO: Use specific order (aw-webui should be one of the first, for example)
148-
summary_subrepos = run(f"git submodule summary {prev_release}")
132+
summary_subrepos = run(
133+
f"git submodule summary {commitrange.split('...')[0]}", cwd=path
134+
)
149135
for s in summary_subrepos.split("\n\n"):
150136
lines = s.split("\n")
151137
header = lines[0]
138+
if header.startswith("fatal: not a git repository"):
139+
# Happens when a submodule has been removed
140+
continue
152141
if header.strip():
153-
print("\n")
142+
out += "\n"
154143
_, name, commitrange, count = header.split(" ")
155144
name = name.strip(".").strip("/")
156145

157-
output, submodules = summary_repo(
158-
f"./{name}", commitrange, filter_types=filter_types
146+
output = summary_repo(
147+
f"{path}/{name}", commitrange, filter_types=filter_types
159148
)
160-
print(output)
149+
out += output
150+
151+
return out
152+
153+
154+
def build(filter_types=["build", "ci", "tests"]):
155+
prev_release = run("git describe --tags --abbrev=0").strip()
156+
output = summary_repo(
157+
".", commitrange=f"{prev_release}...master", filter_types=filter_types
158+
)
159+
print(output)
161160

162161

163162
if __name__ == "__main__":

0 commit comments

Comments
 (0)