Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Also render title in markdown template without name #587

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/587.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The default Markdown template now renders a title containing the release version and date, even when the `name` configuration is left empty.
2 changes: 1 addition & 1 deletion src/towncrier/templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% if versiondata.name %}
# {{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
{% else %}
{{ versiondata.version }} ({{ versiondata.date }})
# {{ versiondata.version }} ({{ versiondata.date }})
{% endif %}
{% endif %}
{% for section, _ in sections.items() %}
Expand Down
47 changes: 47 additions & 0 deletions src/towncrier/test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,53 @@ def test_default_start_string_markdown(self, runner):

self.assertEqual(expected_output, output)

@with_project(
config="""
[tool.towncrier]
name = ""
directory = "changes"
adiroiban marked this conversation as resolved.
Show resolved Hide resolved
filename = "NEWS.md"
version = "1.2.3"
"""
)
def test_markdown_no_name_title(self, runner):
"""
When configured with an empty `name` option,
the default template used for Markdown
renders the title of the release note with just
the version number and release date.
"""
write("changes/123.feature", "Adds levitation")
write(
"NEWS.md",
contents="""
A line

<!-- towncrier release notes start -->
""",
dedent=True,
)

result = runner.invoke(_main, ["--date", "01-01-2001"], catch_exceptions=False)
self.assertEqual(0, result.exit_code, result.output)
output = read("NEWS.md")

expected_output = dedent(
"""
A line

<!-- towncrier release notes start -->

# 1.2.3 (01-01-2001)

### Features

- Adds levitation (#123)
"""
)

self.assertEqual(expected_output, output)

@with_project(
config="""
[tool.towncrier]
Expand Down
Loading