From f6f2fe07b61e8fa8bd812bbc63a51d3f9705a448 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Tue, 23 Nov 2021 20:29:58 +0000 Subject: [PATCH] chore: update duties.py with latest changelog duty --- duties.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/duties.py b/duties.py index a854afe..3d4574a 100644 --- a/duties.py +++ b/duties.py @@ -331,16 +331,19 @@ def changelog(ctx, planned_release: Optional[str] = None): ctx: The context instance (passed automatically). planned_release (str, optional): The planned release version. Example: v1.0.2 """ - if planned_release is not None: - changelog = ctx.run(["git", "cliff", "--tag", planned_release]) - else: - changelog = ctx.run(["git", "cliff"]) + generated_changelog = ctx.run(["git", "cliff", "-u", "-t", planned_release, "-s", "header"])[:-1] + new_changelog = [] changelog_file = pathlib.Path(".") / "CHANGELOG.md" + with changelog_file.open("r", encoding="utf-8") as changelog_contents: + all_lines = changelog_contents.readlines() + for line_string in all_lines: + regex_string = re.search(r"()", line_string) + new_changelog.append(line_string) + if isinstance(regex_string, re.Match): + new_changelog.append(generated_changelog) with changelog_file.open("w", encoding="utf-8") as changelog_contents: - changelog_contents.write(changelog) - - + changelog_contents.writelines(new_changelog) def rm_tree(directory: pathlib.Path):