Skip to content

SW-21: Pin shell scripts to LF via .gitattributes - #22

Closed
developzoneio wants to merge 1 commit into
mainfrom
fix/sw-21-gitattributes-lf
Closed

SW-21: Pin shell scripts to LF via .gitattributes#22
developzoneio wants to merge 1 commit into
mainfrom
fix/sw-21-gitattributes-lf

Conversation

@developzoneio

Copy link
Copy Markdown
Owner

Summary

Adds a repo-root .gitattributes so shell scripts stop checking out as CRLF on Windows. With
core.autocrlf=true (Git's default on Windows and on the windows-latest CI runner) the repo had
no .gitattributes, so every tracked *.sh / *.ps1 was stored LF in the index but checked out
CRLF. A #!/usr/bin/env bash line with a trailing CR makes the kernel look for interpreter bash\r
(bad interpreter error); heredocs and [[ ... ]] comparisons also mis-parse on a trailing CR.

Policy applied: * text=auto default, plus *.sh and *.ps1 pinned to text eol=lf.

⚠️ One-time renormalization

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 --renormalize produced 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: no
SW-18 commit, no tests/lessons/ directory, no scripts/selftest-docs.*. So this creates a fresh
file rather than folding an existing rule. Also, exposure is broader than the ticket stated: CI's
windows-latest runner already runs bash scripts/*.sh on a CRLF checkout, passing only because
Git Bash tolerates the CR today - this hardens that fragile path.

Verification

  • Fresh clone: git ls-files --eol reports w/lf + attr/text eol=lf for all 14 scripts; 0 CR
    bytes across all .sh; shebang ends bash \n.
  • bash -n parses every shell script.
  • scripts/validate.sh -> [OK] All checks passed; ASCII rule clean on all *.ps1.
  • scripts/smoke-hooks.sh local failures are pre-existing/environmental (jq absent locally;
    identical on the pre-change baseline). Green on CI where jq is present.

Closes SW-21.

🤖 Generated with Claude Code

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>
@developzoneio

Copy link
Copy Markdown
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.

@developzoneio
developzoneio deleted the fix/sw-21-gitattributes-lf branch July 23, 2026 14:54
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