From 8c316a57cbf957a36cf6ed1743656aaa3cb9b22b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 29 Jun 2026 00:53:07 -0400 Subject: [PATCH] fix(apidump): make API-baseline comparison line-ending agnostic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestPublicAPIBaseline compared the generated API (LF-joined) against the raw golden bytes. On a Windows checkout (autocrlf), the committed api_baseline.txt goldens carry CRLF, so every line mismatched despite identical content — the release workflow's build-and-test (windows-latest) failed the baseline tests for all V4 packages, while the ubuntu Unit Lane passed. Normalize CRLF->LF on the golden before comparing, so the gate is stable across platforms and checkout line-ending settings. Co-Authored-By: Claude Opus 4.8 (1M context) --- internal/apidump/apidump.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/apidump/apidump.go b/internal/apidump/apidump.go index 96cf4302..9930db6f 100644 --- a/internal/apidump/apidump.go +++ b/internal/apidump/apidump.go @@ -167,7 +167,11 @@ func Check(parseT testing.TB, parseDir, parseGolden string) { if parseErr != nil { parseT.Fatalf("read golden %s (generate it with UPDATE_API_BASELINE=1): %v", parseGolden, parseErr) } - if string(parseWant) != parseGot { + // Normalize line endings before comparing: the generated API uses "\n", but a golden file + // checked out on Windows (autocrlf) carries "\r\n", which would otherwise fail the comparison + // on every line despite identical content. This keeps the gate stable across platforms/checkouts. + parseWantNormalized := strings.ReplaceAll(string(parseWant), "\r\n", "\n") + if parseWantNormalized != parseGot { parseT.Fatalf("public API of %s changed.\nIf intentional, regenerate with UPDATE_API_BASELINE=1 and review the diff.\n\n--- current API ---\n%s", parseDir, parseGot) } }