fix(tools): say "Maintenance release." in titled notes without listed changes

The fallback tested the builder's length, which the title line already made
non-zero, so release.yml (always --title) published notes that were only a
heading when a release held chore, ci, test or refactor commits alone. The
fallback now depends on whether a section or breaking entry was written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 10:28:55 +00:00
1 parent c11c996bc6
commit 81f10379c8
2 files changed
+38 -1

No files matched your search

@@ -60,11 +60,14 @@ internal sealed partial class ChangelogCommand : ICommand
var sb = new StringBuilder();
if (title is not null) sb.Append("# ").AppendLine(title).AppendLine();
// The title alone says nothing about the release: the fallback depends on the entries written, not on the text.
var written = false;
if (breaking.Count > 0)
{
sb.AppendLine("### Breaking changes");
foreach (var e in breaking) sb.AppendLine(e);
sb.AppendLine();
written = true;
}
foreach (var (type, heading) in Sections)
{
@@ -72,8 +75,9 @@ internal sealed partial class ChangelogCommand : ICommand
sb.Append("### ").AppendLine(heading);
foreach (var e in entries) sb.AppendLine(e);
sb.AppendLine();
written = true;
}
if (sb.Length == 0) sb.AppendLine("Maintenance release.");
if (!written) sb.AppendLine("Maintenance release.");
return sb.ToString();
}
@@ -0,0 +1,33 @@
using Titano.Testing;
using Titano.Tools.Commands;
namespace Titano.Tools.Tests;
/// <summary>Release notes from Conventional Commits (BRIEF §19.3), as release.yml renders them with a title.</summary>
public sealed class ChangelogCommandTests
{
[Test]
public void EntriesAreGroupedByTypeUnderTheTitle()
{
var notes = ChangelogCommand.Render(["abc1234\tfeat(editor): save the project as a .titano file", "def5678\tfix: keep user data", "0a1b2c3\tchore: bump"], "Titano 1.2.0");
Assert.Equal(
"# Titano 1.2.0\n\n### Added\n- **editor**: save the project as a .titano file (abc1234)\n\n### Fixed\n- keep user data (def5678)\n\n",
notes.ReplaceLineEndings("\n"));
}
[Test]
public void ATitledReleaseWithoutListedChangesSaysItIsAMaintenanceRelease()
{
string[] lines = ["abc1234\tchore: bump", "def5678\tci: cache", "0a1b2c3\ttest(setup): cover uninstall", "not a conventional subject"];
Assert.Equal("# Titano 1.2.1\n\nMaintenance release.\n", ChangelogCommand.Render(lines, "Titano 1.2.1").ReplaceLineEndings("\n"));
Assert.Equal("Maintenance release.\n", ChangelogCommand.Render(lines, null).ReplaceLineEndings("\n"));
Assert.Equal("Maintenance release.\n", ChangelogCommand.Render([], null).ReplaceLineEndings("\n"));
}
[Test]
public void ABreakingChangeOfAnUnlistedTypeIsStillWritten()
{
var notes = ChangelogCommand.Render(["abc1234\trefactor(core)!: rename the archive layout"], "Titano 2.0.0").ReplaceLineEndings("\n");
Assert.Equal("# Titano 2.0.0\n\n### Breaking changes\n- **core**: rename the archive layout (abc1234)\n\n", notes);
}
}