Skip to content

codegen: keep generated fixtures on LF - #425

Merged
somanshreddy merged 1 commit into
mainfrom
10-07-keep_generated_fixtures_lf
Oct 7, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
10-07-keep_generated_fixtures_lf

Conversation

@somanshreddy

Copy link
Copy Markdown
Collaborator

Scope

Surfaces: CLI (developer checkout) | Module: Codegen tests

Summary

On Windows with core.autocrlf=true, a clean checkout fails three codegen tests, because the checked-in fixtures arrive as CRLF while codegen writes LF. A one-line .gitattributes pins LF on checkout. Contributed by @dajiaohuang in #340 and recreated here as a signed commit with their co-author credit, since the org requires signed commits and an unsigned fork commit cannot be squash-merged.

Fixes #339

Root cause

Every tracked text file is LF in the repository, but with no .gitattributes, core.autocrlf=true converts them to CRLF in a Windows working tree. TestGoldenFiles compares codegen's LF output byte for byte against the now-CRLF fixtures, and both surface-allowlist tests match line ends with a regex that the trailing \r breaks.

Fix

* text=auto eol=lf: files git detects as text check out as LF everywhere; binary detection is unchanged (docs/demo.gif stays binary). It changes nothing stored in the repository (git add --renormalize . is a no-op) and nothing on Linux or macOS. Release builds run on Linux from main and nothing is embedded, so no shipped artifact can change. The rule only sets line endings: it names no filter, diff or merge driver, so it cannot cause git to run anything.

A future file that genuinely needs CRLF will need its own attribute line.

Testing

Reproduced on Linux by forcing a CRLF checkout (core.autocrlf=true, core.eol=crlf): exactly the three tests from #339 fail, every other package passes, and regenerating gen/ from CRLF inputs leaves no carriage returns. With this rule the same checkout passes. make lint and make test pass.

🤖 Generated with Claude Code

On a Windows checkout with core.autocrlf=true, the codegen golden and
surface-allowlist fixtures check out as CRLF while codegen writes LF, so
TestGoldenFiles and both surface-allowlist tests fail. Every tracked text
file is already LF in the repository; this pins LF on checkout too.

Contributed by @dajiaohuang in #340; recreated here as a signed commit,
since the org requires signed commits and an unsigned fork commit cannot
be squash-merged.

Fixes #339

Co-authored-by: dajiaohuang <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@terencechotai2-commits terencechotai2-commits left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

Note that the rule is repo-wide (* text=auto eol=lf), not scoped to gen/ or the golden fixtures. I checked whether that reaches anything it shouldn't, and it doesn't:

  • Index: git ls-files --eol shows all 210 text files as i/lf. The only non-text file is docs/demo.gif, and git still detects it as binary (-text).
  • Renormalize: git add --renormalize . is a no-op.
  • No CRLF-needing files: there are no .bat, .cmd, .ps1 or .sln files. The two .sh scripts benefit from staying LF on Windows.
  • Simulated Windows checkout (core.autocrlf=true, core.eol=crlf): on main, 206 files check out with CR bytes. With this PR, only demo.gif has any CR bytes, and it's byte-identical to the original.
  • No drivers: there's no filter, diff or merge driver, so nothing executes.

— tai2

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at a3aee8b2.

  • Same change as #340: the .gitattributes blob (6313b56) is identical to @dajiaohuang's, and the commit carries their Co-authored-by. GitHub shows the signature as verified.
  • Nothing in the repository changes: git add --renormalize . leaves the tree clean. git ls-files --eol shows all 210 text files as i/lf, and the one remaining file is docs/demo.gif, detected as binary (-text), so text=auto won't touch it.
  • No CRLF needs: no tracked file needs CRLF today. scripts/install.sh gets eol=lf, which is what it needs to run from a Windows checkout under Git Bash or WSL.

tai2's simulated Windows checkout covers the before/after; I have nothing to add to it.

— Rames

@somanshreddy
somanshreddy merged commit 3485904 into main Oct 7, 2026
10 checks passed
@somanshreddy
somanshreddy deleted the 10-07-keep_generated_fixtures_lf branch October 7, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants