Skip to content

chore: normalize line endings to LF via .gitattributes - #5229

Open
HelloOjasMutreja wants to merge 1 commit into
facebook:mainfrom
HelloOjasMutreja:infra/gitattributes-lf-normalize
Open

chore: normalize line endings to LF via .gitattributes#5229
HelloOjasMutreja wants to merge 1 commit into
facebook:mainfrom
HelloOjasMutreja:infra/gitattributes-lf-normalize

Conversation

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor

Not tied to a filed issue; found while shipping an unrelated fix, when scripts/generate-cldr-weekdays.mjs --check (from the recently-merged Calendar CLDR PR) failed on a completely default Windows checkout, immediately after running the generator itself.

Root cause

The check does:

const actual = fs.readFileSync(OUTPUT_FILE, 'utf8');
if (actual !== expected) { /* report stale */ }

expected is built from a template literal plus Prettier's format(), both of which always emit \n. actual is read exactly as the file sits on disk. Git's default core.autocrlf=true on Windows converts checked-in LF files to CRLF on checkout, so actual has CRLF line endings while expected has LF. The byte-for-byte comparison then fails on every default Windows checkout, regardless of whether the data is actually stale.

Confirmed: forcing a fresh LF checkout of the same file (bypassing autocrlf) makes the exact same check pass immediately, with zero real content difference. This isn't specific to the CLDR script either, it's a latent risk for any current or future script that does a similar regenerate-and-diff check.

Fix

Add a .gitattributes rule forcing LF line endings on checkout for all text files:

* text=auto eol=lf

This is the standard fix for this exact class of problem (also used by many JS/TS monorepos), and normalizes checkouts going forward for every Windows contributor without needing anyone to change their local core.autocrlf. It doesn't touch any already-committed blob content, only how files are materialized on checkout/add from here on.

Verification

node scripts/generate-cldr-weekdays.mjs --check passes on a normal checkout. Ran the full BottomSheet suite (180 tests) as a sanity check that nothing else regressed; unaffected as expected, since this only changes checkout-time line-ending handling. No changeset since this touches no published package.

Windows checkouts default to core.autocrlf=true, which converts
checked-in LF files to CRLF on disk. Any script that regenerates a
checked-in file and diffs it byte-for-byte against freshly-generated
content (which Prettier/Node write as LF) then fails on every such
machine, regardless of whether the data is actually stale.

Confirmed with scripts/generate-cldr-weekdays.mjs --check: it always
reported stale data on a default Windows checkout even immediately
after running the generator, since the comparison was LF-generated
content against a CRLF-checked-out file. Forcing eol=lf for all text
files removes the mismatch at the source, for every future checkout.
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 19, 2026 8:00pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 19, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 19, 2026
@HelloOjasMutreja
HelloOjasMutreja marked this pull request as ready for review August 20, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant