chore: update duties.py with latest changelog duty

This commit is contained in:
2021-11-23 20:29:58 +00:00
parent 7ee36f28b5
commit f6f2fe07b6

View File

@@ -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"(<!-- marker -->)", 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):