Repository navigation
codegen: keep generated fixtures on LF - #425
Merged
Merged
Conversation
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
left a comment
There was a problem hiding this comment.
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 --eolshows all 210 text files asi/lf. The only non-text file isdocs/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,.ps1or.slnfiles. The two.shscripts benefit from staying LF on Windows. - Simulated Windows checkout (
core.autocrlf=true,core.eol=crlf): onmain, 206 files check out with CR bytes. With this PR, onlydemo.gifhas 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
approved these changes
Oct 7, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approving at a3aee8b2.
- Same change as #340: the
.gitattributesblob (6313b56) is identical to @dajiaohuang's, and the commit carries theirCo-authored-by. GitHub shows the signature as verified. - Nothing in the repository changes:
git add --renormalize .leaves the tree clean.git ls-files --eolshows all 210 text files asi/lf, and the one remaining file isdocs/demo.gif, detected as binary (-text), sotext=autowon't touch it. - No CRLF needs: no tracked file needs CRLF today.
scripts/install.shgetseol=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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.gitattributespins 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=trueconverts them to CRLF in a Windows working tree.TestGoldenFilescompares 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\rbreaks.Fix
* text=auto eol=lf: files git detects as text check out as LF everywhere; binary detection is unchanged (docs/demo.gifstays 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 frommainand 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 regeneratinggen/from CRLF inputs leaves no carriage returns. With this rule the same checkout passes.make lintandmake testpass.🤖 Generated with Claude Code