Skip to content

Commit

Permalink
Merge branch 'trunk' into ik/1conf2rulethemall
Browse files Browse the repository at this point in the history
  • Loading branch information
adiroiban authored Oct 22, 2023
2 parents f2e9f6f + 3f24b6e commit b5917d3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/towncrier/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,4 @@ def get_indent(text: str) -> str:
else:
done.append(line)

return "\n".join(done).rstrip() + "\n"
return "\n".join(done)
8 changes: 3 additions & 5 deletions src/towncrier/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ def append_to_newsfile(
with news_file.open("w", encoding="utf8", newline="") as f:
if header:
f.write(header)

f.write(content)

if prev_body:
f.write(f"\n\n{prev_body}")
# If there is no previous body that means we're writing a brand new news file.
# We don't want extra whitespace at the end of this new file.
f.write(content + prev_body if prev_body else content.rstrip() + "\n")


def _figure_out_existing_content(
Expand Down
4 changes: 4 additions & 0 deletions src/towncrier/newsfragments/552.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Two newlines are no longer always added between the current release notes and the previous content.
The newlines are now defined only inside the template.

**Important! If you're using a custom template and want to keep the same whitespace between releases, you may have to modify your template.**
6 changes: 5 additions & 1 deletion src/towncrier/templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ No significant changes.
No significant changes.

{% endif %}
{% endfor %}
{% endfor +%}
{#
This comment adds one more newline at the end of the rendered newsfile content.
In this way the there are 2 newlines between the latest release and the previous release content.
#}
17 changes: 17 additions & 0 deletions src/towncrier/test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def _test_command(self, command):
- Another orphaned feature
- Orphaned feature
"""
),
)
Expand Down Expand Up @@ -334,6 +336,8 @@ def run_order_scenario(sections, types):
- section-b type-2 (#1)
"""
),
)
Expand Down Expand Up @@ -377,6 +381,8 @@ def run_order_scenario(sections, types):
- section-a type-1 (#1)
"""
),
)
Expand Down Expand Up @@ -603,6 +609,8 @@ def test_projectless_changelog(self):
- Adds levitation (#123)
- Extends levitation (#124)
"""
).lstrip(),
)
Expand Down Expand Up @@ -643,6 +651,8 @@ def test_version_in_config(self):
- Adds levitation (#123)
"""
).lstrip(),
)
Expand Down Expand Up @@ -685,6 +695,8 @@ def test_project_name_in_config(self):
- Adds levitation (#123)
"""
).lstrip(),
)
Expand Down Expand Up @@ -730,6 +742,8 @@ def test_no_package_changelog(self):
- Adds levitation (#123)
"""
).lstrip(),
)
Expand Down Expand Up @@ -1062,6 +1076,8 @@ def test_title_format_custom(self):
- Adds levitation (#123)
- Extends levitation (#124)
"""
)

Expand Down Expand Up @@ -1366,6 +1382,7 @@ def test_with_topline_and_template_and_draft(self):
- Adds levitation
"""
)

Expand Down
14 changes: 14 additions & 0 deletions src/towncrier/test/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def test_basic(self):
~~~~~~~~
- Web fixed. (#3)
"""

template = read_pkg_resource("templates/default.rst")
Expand Down Expand Up @@ -154,6 +156,8 @@ def test_basic(self):
^^^^^^^^
- Web fixed. (#3)
"""

output = render_fragments(
Expand Down Expand Up @@ -229,6 +233,8 @@ def test_markdown(self):
(#2)
- Web fixed. (#3)
"""

template = read_pkg_resource("templates/default.md")
Expand Down Expand Up @@ -291,6 +297,8 @@ def test_markdown(self):
[2]: https://github.com/twisted/towncrier/issues/2
[3]: https://github.com/twisted/towncrier/issues/3
"""

output = render_fragments(
Expand Down Expand Up @@ -332,6 +340,8 @@ def test_issue_format(self):
----
- xxbar, xx1, xx9, xx142
"""

template = read_pkg_resource("templates/default.rst")
Expand Down Expand Up @@ -386,6 +396,8 @@ def test_line_wrapping(self):
- a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a (#3)
"""

template = read_pkg_resource("templates/default.rst")
Expand Down Expand Up @@ -433,6 +445,8 @@ def test_line_wrapping_disabled(self):
- asdf asdf asdf asdf looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong newsfragment. (#1)
- https://google.com/q=?---------------------------------------------------------------------------------------------------- (#2)
- a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a (#3)
""" # NOQA

template = read_pkg_resource("templates/default.rst")
Expand Down

0 comments on commit b5917d3

Please sign in to comment.