Skip to content

Commit

Permalink
fix(changelog): make sure default templates render ending in 1 newline
Browse files Browse the repository at this point in the history
  • Loading branch information
codejedi365 authored and relekang committed Mar 18, 2024
1 parent 77c3816 commit 0b4a45e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions semantic_release/cli/commands/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def changelog(ctx: click.Context, release_tag: str | None = None) -> None:
)
else:
changelog_text = render_default_changelog_file(env)
changelog_file.write_text(changelog_text, encoding="utf-8")
changelog_file.write_text(f"{changelog_text}\n", encoding="utf-8")

else:
if runtime.global_cli_options.noop:
Expand Down Expand Up @@ -112,7 +112,7 @@ def changelog(ctx: click.Context, release_tag: str | None = None) -> None:
else:
try:
hvcs_client.create_or_update_release(
release_tag, release_notes, prerelease=version.is_prerelease
release_tag, f"{release_notes}\n", prerelease=version.is_prerelease
)
except Exception as e:
log.exception(e)
Expand Down
2 changes: 1 addition & 1 deletion semantic_release/cli/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def version( # noqa: C901
)
else:
changelog_text = render_default_changelog_file(env)
changelog_file.write_text(changelog_text, encoding="utf-8")
changelog_file.write_text(f"{changelog_text}\n", encoding="utf-8")

updated_paths = [str(changelog_file.relative_to(repo.working_dir))]

Expand Down
4 changes: 2 additions & 2 deletions semantic_release/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def render_default_changelog_file(template_environment: Environment) -> str:
.read_text(encoding="utf-8")
)
tmpl = template_environment.from_string(changelog_text)
return tmpl.render()
return tmpl.render().rstrip()


def render_release_notes(
Expand All @@ -45,4 +45,4 @@ def render_release_notes(
) -> str:
return template_environment.from_string(release_notes_template).render(
version=version, release=release
)
).rstrip()

0 comments on commit 0b4a45e

Please sign in to comment.