Skip to content

Commit 39ea5d8

Browse files
committed
canonicalize generated markdown line endings
1 parent beed8c9 commit 39ea5d8

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

boatstack/export_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ func TestExportAndDriftCheck(t *testing.T) {
524524
}
525525
}
526526

527+
func TestGeneratedMarkdownIsIndependentOfBuilderLineEndings(t *testing.T) {
528+
want := GeneratedMarkdown("# Contract\n\nStable bytes.\n")
529+
got := GeneratedMarkdown("# Contract\r\n\r\nStable bytes.\r\n")
530+
if string(got) != string(want) {
531+
t.Fatalf("generated Markdown retained builder line endings:\nwant %q\n got %q", want, got)
532+
}
533+
}
534+
527535
func TestExportPreservesOptionalChangelogPolicy(t *testing.T) {
528536
config := testConfig()
529537
config.Workflow.MaintainChangelog = true

boatstack/runtime.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ func GeneratedJSON(value any) ([]byte, error) {
234234
}
235235

236236
func GeneratedMarkdown(body string) []byte {
237+
body = strings.ReplaceAll(body, "\r\n", "\n")
238+
body = strings.ReplaceAll(body, "\r", "\n")
237239
return []byte(fmt.Sprintf("<!-- %s -->\n\n%s\n", Marker, strings.TrimSpace(body)))
238240
}
239241

0 commit comments

Comments
 (0)