ci: check every text file out as LF so the Windows test leg sees the same bytes by Jocs · Pull Request #5447 · marktext/marktext · GitHub
Skip to content

ci: check every text file out as LF so the Windows test leg sees the same bytes - #5447

Merged
Jocs merged 2 commits into
developfrom
fix/normalize-line-endings
Sep 18, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/normalize-line-endings

Conversation

@Jocs

@Jocs Jocs commented Sep 18, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #5323, which added a windows-latest leg to the unit-test matrix.

GitHub's Windows runner images set core.autocrlf=true globally, and this repo declares no attributes of its own. So as of that PR the two matrix legs no longer test the same bytes: every text file is checked out LF on ubuntu-latest and CRLF on windows-latest.

That matters because several specs read tracked source files and parse them as text:

  • source-code-image-action.spec.ts and search-prefill.spec.ts read a .vue, compile it, then .split('\n') the output to strip import lines;
  • empty-state-button-contrast.spec.ts regex-matches the components' scoped CSS and the theme stylesheets to pull custom-property names.

They pass on Windows today only because those particular patterns happen to tolerate a trailing \r. The next assertion that doesn't — an m-flagged $ (which will not match before a \r\n), a toBe on a split line, a snippet holding a literal \n, a snapshot — goes red on Windows alone, and the cause is invisible in a diff and unreproducible on macOS or Linux. test/unit/markdown.ts:8 already carries an explicit .replace(/(?:\r\n|\n)/g, '\n'), so this has cost someone time before; that fix was local to one helper and left the class open.

* text=auto eol=lf normalizes on commit and checks out LF on every platform, closing the class in one line. It also keeps a Windows contributor's editor from turning a whole file into a diff on save.

No file in the tree needs CRLF: there are no .bat, .cmd or .ps1 files, and the single NSIS include (packages/desktop/build/windows/installer.nsh) reads LF fine.

Commits

  1. ci: check every text file out as LF on all platforms — adds .gitattributes.
  2. ci: renormalize the two files stored with CRLF — the two vendored Open Sans licence texts were committed with CRLF, so their blobs no longer match what git would store for the same working-tree content; left alone they surface as spurious modifications the first time git compares by content rather than by stat cache. Kept as its own commit, as git's documentation advises, so the one-line policy change stays reviewable next to 808 lines of mechanical churn.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Notes for reviewers

The renormalization is line-endings only — git diff --ignore-cr-at-eol across the two commits is empty. After it, no blob in the tree contains a CR at end of line (git grep --cached -lIP "\r$" returns nothing) and the working tree is clean.

🤖 Generated with Claude Code

Jocs and others added 2 commits September 18, 2026 18:34
#5323 added a `windows-latest` leg to the unit-test matrix. GitHub's Windows
runner images set `core.autocrlf=true` globally and the repo declares no
attributes, so from now on the two legs test different bytes: every text file
arrives LF on Linux and CRLF on Windows.

Several specs read tracked source files and parse them as text —
source-code-image-action.spec.ts and search-prefill.spec.ts compile a .vue and
split its output on '\n', empty-state-button-contrast.spec.ts regex-matches the
components' scoped CSS. They pass today only because those patterns happen to
tolerate a trailing '\r'. An `m`-flagged `$`, a `toBe` on a split line, or any
assertion holding a literal '\n' would fail on Windows alone, and the cause is
invisible in a diff: test/unit/markdown.ts already carries an explicit
`.replace(/(?:\r\n|\n)/g, '\n')` from the last time this bit someone.

`* text=auto eol=lf` normalizes on commit and checks out LF everywhere, which
also keeps a Windows contributor's working tree from turning a whole file into
a diff. There are no .bat/.cmd/.ps1 files needing CRLF; the one NSIS include,
packages/desktop/build/windows/installer.nsh, reads LF fine.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`* text=auto eol=lf` normalizes on add, so the two blobs that were committed
with CRLF no longer match what git would now store for the same working-tree
content. Left alone they surface as spurious modifications the first time git
compares them by content rather than by stat cache.

Both are vendored Open Sans licence texts and the change is CR-at-EOL only:
`git diff --ignore-cr-at-eol` between the two revisions is empty. Kept separate
from the attribute itself, as git's own documentation advises, so the one-line
policy change stays reviewable next to 808 lines of mechanical churn.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5447:

Run: https://github.com/marktext/marktext/actions/runs/35335973618

Artifact Size Link
marktext-macos-x64 297.7 MB Download
marktext-windows-arm64 279.4 MB Download
marktext-linux 638.1 MB Download
marktext-windows-x64 287.6 MB Download
marktext-macos-arm64 287.4 MB Download

@Jocs
Jocs merged commit 187a1f9 into develop Sep 18, 2026
18 checks passed
@Jocs
Jocs deleted the fix/normalize-line-endings branch September 18, 2026 11:05
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.

1 participant