SW-21: Pin shell scripts to LF via .gitattributes - #22
Closed
developzoneio wants to merge 1 commit into
Closed
Conversation
Add a repo-root .gitattributes with `* text=auto` and `*.sh`/`*.ps1` pinned to `eol=lf`. Without it, core.autocrlf=true checks scripts out as CRLF on Windows, putting a trailing CR on `#!/usr/bin/env bash` shebangs (bad interpreter) and mis-parsing heredocs and `[[ ... ]]`. The first checkout after this lands renormalizes line endings in existing Windows working trees - a one-time large diff, not a change. SW-21 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded: the SW-21 .gitattributes fix was merged into feature/optimize-workflow/v1 (commit 8a8e0be), which folds it together with the existing narrow tests/** fixture pins. Closing this standalone PR to avoid a duplicate merge into main. |
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.
Summary
Adds a repo-root
.gitattributesso shell scripts stop checking out as CRLF on Windows. Withcore.autocrlf=true(Git's default on Windows and on thewindows-latestCI runner) the repo hadno
.gitattributes, so every tracked*.sh/*.ps1was stored LF in the index but checked outCRLF. A
#!/usr/bin/env bashline with a trailing CR makes the kernel look for interpreterbash\r(
bad interpretererror); heredocs and[[ ... ]]comparisons also mis-parse on a trailing CR.Policy applied:
* text=autodefault, plus*.shand*.ps1pinned totext eol=lf.The first checkout after this lands rewrites line endings in existing Windows working trees. It
looks like a large diff but is a one-time renormalization, not a content change. The index was
already all-LF, so
git add --renormalizeproduced no content churn.Notes (ticket premise was stale)
The ticket assumed SW-18 had added a narrow
tests/lessons/**rule to fold in. Verified false: noSW-18 commit, no
tests/lessons/directory, noscripts/selftest-docs.*. So this creates a freshfile rather than folding an existing rule. Also, exposure is broader than the ticket stated: CI's
windows-latestrunner already runsbash scripts/*.shon a CRLF checkout, passing only becauseGit Bash tolerates the CR today - this hardens that fragile path.
Verification
git ls-files --eolreportsw/lf+attr/text eol=lffor all 14 scripts; 0 CRbytes across all
.sh; shebang endsbash \n.bash -nparses every shell script.scripts/validate.sh->[OK] All checks passed; ASCII rule clean on all*.ps1.scripts/smoke-hooks.shlocal failures are pre-existing/environmental (jqabsent locally;identical on the pre-change baseline). Green on CI where
jqis present.Closes SW-21.
🤖 Generated with Claude Code