Skip to content
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
2 changes: 1 addition & 1 deletion requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ sections:
tests:
- "BuildMark_MarkdownReportGeneration"
- "BuildInformation_ToMarkdown_RespectsCustomHeadingDepth"
- "BuildInformation_ToMarkdown_UsesCorrectTableWidths"
- "BuildInformation_ToMarkdown_UsesBulletLists"
- "BuildInformation_ToMarkdown_HandlesFirstReleaseWithNA"
- "BuildInformation_ToMarkdown_ExcludesFullChangelogWhenNoBaseline"

Expand Down
24 changes: 9 additions & 15 deletions src/DemaConsulting.BuildMark/BuildInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,21 @@ private void AppendVersionInformation(System.Text.StringBuilder markdown, string
/// <param name="subHeading">Sub-heading prefix.</param>
private void AppendChangesSection(System.Text.StringBuilder markdown, string subHeading)
{
// Add changes section header and table structure
// Add changes section header
markdown.AppendLine($"{subHeading} Changes");
markdown.AppendLine();
markdown.AppendLine("| Issue | Title |");
markdown.AppendLine("| :-: | :---------- |");

// Add change items or N/A if no changes exist
if (Changes.Count > 0)
{
foreach (var issue in Changes)
{
markdown.AppendLine($"| [{issue.Id}]({issue.Url}) | {issue.Title} |");
markdown.AppendLine($"- [{issue.Id}]({issue.Url}) - {issue.Title}");
}
}
else
{
markdown.AppendLine("| N/A | N/A |");
markdown.AppendLine("- N/A");
}

// Add blank line after section
Expand All @@ -149,23 +147,21 @@ private void AppendChangesSection(System.Text.StringBuilder markdown, string sub
/// <param name="subHeading">Sub-heading prefix.</param>
private void AppendBugsFixedSection(System.Text.StringBuilder markdown, string subHeading)
{
// Add bugs fixed section header and table structure
// Add bugs fixed section header
markdown.AppendLine($"{subHeading} Bugs Fixed");
markdown.AppendLine();
markdown.AppendLine("| Issue | Title |");
markdown.AppendLine("| :-: | :---------- |");

// Add bug items or N/A if no bugs were fixed
if (Bugs.Count > 0)
{
foreach (var issue in Bugs)
{
markdown.AppendLine($"| [{issue.Id}]({issue.Url}) | {issue.Title} |");
markdown.AppendLine($"- [{issue.Id}]({issue.Url}) - {issue.Title}");
}
}
else
{
markdown.AppendLine("| N/A | N/A |");
markdown.AppendLine("- N/A");
}

// Add blank line after section
Expand All @@ -179,23 +175,21 @@ private void AppendBugsFixedSection(System.Text.StringBuilder markdown, string s
/// <param name="subHeading">Sub-heading prefix.</param>
private void AppendKnownIssuesSection(System.Text.StringBuilder markdown, string subHeading)
{
// Add known issues section header and table structure
// Add known issues section header
markdown.AppendLine($"{subHeading} Known Issues");
markdown.AppendLine();
markdown.AppendLine("| Issue | Title |");
markdown.AppendLine("| :-: | :---------- |");

// Add known issue items or N/A if no known issues exist
if (KnownIssues.Count > 0)
{
foreach (var issue in KnownIssues)
{
markdown.AppendLine($"| [{issue.Id}]({issue.Url}) | {issue.Title} |");
markdown.AppendLine($"- [{issue.Id}]({issue.Url}) - {issue.Title}");
}
}
else
{
markdown.AppendLine("| N/A | N/A |");
markdown.AppendLine("- N/A");
}

// Add blank line after section
Expand Down
38 changes: 20 additions & 18 deletions test/DemaConsulting.BuildMark.Tests/BuildInformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ [new ItemInfo("2", "Bug fix", "https://example.com/2", "bug")],
var changesSectionStart = markdown.IndexOf("## Changes", StringComparison.Ordinal);
var bugsSectionStart = markdown.IndexOf("## Bugs Fixed", StringComparison.Ordinal);
var changesSection = markdown.Substring(changesSectionStart, bugsSectionStart - changesSectionStart);
Assert.Contains("| N/A | N/A |", changesSection);
Assert.Contains("- N/A", changesSection);
}

/// <summary>
Expand All @@ -347,11 +347,11 @@ [new ItemInfo("1", "Feature", "https://example.com/1", "feature")],
// Assert - Check that Bugs Fixed section contains N/A
var bugsSectionStart = markdown.IndexOf("## Bugs Fixed", StringComparison.Ordinal);
var bugsSection = markdown.Substring(bugsSectionStart);
Assert.Contains("| N/A | N/A |", bugsSection);
Assert.Contains("- N/A", bugsSection);
}

/// <summary>
/// Test that ToMarkdown includes issue links in tables.
/// Test that ToMarkdown includes issue links in bullet lists.
/// </summary>
[TestMethod]
public async Task BuildInformation_ToMarkdown_IncludesIssueLinks()
Expand All @@ -364,8 +364,8 @@ public async Task BuildInformation_ToMarkdown_IncludesIssueLinks()
var markdown = buildInfo.ToMarkdown();

// Assert - verify issue links are properly formatted
Assert.Contains("[3](https://github.com/example/repo/issues/3)", markdown);
Assert.Contains("[2](https://github.com/example/repo/issues/2)", markdown);
Assert.Contains("- [3](https://github.com/example/repo/issues/3)", markdown);
Assert.Contains("- [2](https://github.com/example/repo/issues/2)", markdown);
}

/// <summary>
Expand Down Expand Up @@ -427,10 +427,10 @@ public async Task BuildInformation_ToMarkdown_ExcludesFullChangelogWhenNoBaselin
}

/// <summary>
/// Test that ToMarkdown uses correct table widths with centered Issue column.
/// Test that ToMarkdown uses bullet lists for changes, bugs, and known issues.
/// </summary>
[TestMethod]
public async Task BuildInformation_ToMarkdown_UsesCorrectTableWidths()
public async Task BuildInformation_ToMarkdown_UsesBulletLists()
{
// Arrange
var connector = new MockRepoConnector();
Expand All @@ -439,23 +439,25 @@ public async Task BuildInformation_ToMarkdown_UsesCorrectTableWidths()
// Act
var markdown = buildInfo.ToMarkdown(includeKnownIssues: true);

// Assert - verify table separators use correct width format (10:1 ratio with centered Issue)
// The separator should have centered Issue column (:-:) and wide left-aligned Title column (:----------)

// Verify the table separator appears in Changes section
// Assert - verify bullet list format is used for changes, bugs, and known issues
// Verify the bullet list appears in Changes section
var changesStart = markdown.IndexOf("## Changes", StringComparison.Ordinal);
var bugsStart = markdown.IndexOf("## Bugs Fixed", StringComparison.Ordinal);
var changesSection = markdown.Substring(changesStart, bugsStart - changesStart);
Assert.Contains("| :-: | :---------- |", changesSection);
Assert.Contains("- [", changesSection);
Assert.DoesNotContain("| :-: | :---------- |", changesSection);

// Verify the table separator appears in Bugs Fixed section
// Verify the bullet list appears in Bugs Fixed section
var knownIssuesStart = markdown.IndexOf("## Known Issues", StringComparison.Ordinal);
var bugsSection = markdown.Substring(bugsStart, knownIssuesStart - bugsStart);
Assert.Contains("| :-: | :---------- |", bugsSection);

// Verify the table separator appears in Known Issues section
var knownIssuesSection = markdown.Substring(knownIssuesStart);
Assert.Contains("| :-: | :---------- |", knownIssuesSection);
Assert.Contains("- [", bugsSection);
Assert.DoesNotContain("| :-: | :---------- |", bugsSection);

// Verify the bullet list appears in Known Issues section
var fullChangelogStart = markdown.IndexOf("## Full Changelog", StringComparison.Ordinal);
var knownIssuesSection = markdown.Substring(knownIssuesStart, fullChangelogStart - knownIssuesStart);
Assert.Contains("- [", knownIssuesSection);
Assert.DoesNotContain("| :-: | :---------- |", knownIssuesSection);
}

/// <summary>
Expand Down