Skip to content

Commit ade74fd

Browse files
authored
build: add --add-version-header flag to build_changelog.py (#1179)
Add optional flag to prepend version header and adjust heading levels, useful for projects that want to include changelogs in their docs with proper heading hierarchy. When enabled: - Adds '# vX.Y.Z' header at the top - Adjusts '# Contributors' to '## Contributors' - Adjusts '# Changelog' to '## Changelog' This keeps the default behavior unchanged while allowing docs-oriented projects (like gptme) to generate properly formatted release notes.
1 parent bd4c5e6 commit ade74fd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scripts/build_changelog.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ def main():
6363
parser.add_argument(
6464
"--output", default="changelog.md", help="Path to output changelog"
6565
)
66+
parser.add_argument(
67+
"--add-version-header",
68+
action="store_true",
69+
help="Add version header and adjust heading levels for docs",
70+
)
6671

6772
# parse args
6873
args = parser.parse_args()
@@ -88,6 +93,7 @@ def main():
8893
commit_range=(since, until),
8994
output_path=args.output,
9095
repo_order=repo_order,
96+
add_version_header=args.add_version_header,
9197
)
9298

9399

@@ -352,6 +358,7 @@ def build(
352358
output_path: str,
353359
repo_order: List[str],
354360
filter_types: Optional[List[str]] = None,
361+
add_version_header: bool = False,
355362
):
356363
# provides a commit summary for the repo and subrepos, recursively looking up subrepos
357364
# NOTE: this must be done *before* `get_all_contributors` is called,
@@ -423,6 +430,12 @@ def build(
423430

424431
if repo == "activitywatch":
425432
output = output.replace("# activitywatch", "# activitywatch (bundle repo)")
433+
434+
if add_version_header:
435+
output = f"# {tag}\n\n" + output
436+
output = output.replace("\n# Contributors\n", "\n## Contributors\n")
437+
output = output.replace("\n# Changelog\n", "\n## Changelog\n")
438+
426439
with open(output_path, "w") as f:
427440
f.write(output)
428441
print(f"Wrote {len(output.splitlines())} lines to {output_path}")

0 commit comments

Comments
 (0)