Skip to content

chore: sync *.ps1 EOL fix from canonical#91

Merged
Chris-Wolfgang merged 3 commits into
mainfrom
chore/sync-ps1-eol-from-canonical
May 14, 2026
Merged

chore: sync *.ps1 EOL fix from canonical#91
Chris-Wolfgang merged 3 commits into
mainfrom
chore/sync-ps1-eol-from-canonical

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

Syncs the canonical *.ps1 EOL fix from repo-template#347 + #348. Removes the CRLF + UTF-8-BOM overrides for *.ps1 files in .gitattributes and .editorconfig.

Why

The #!/usr/bin/env pwsh shebang at the top of every script in scripts/ doesn't work as an executable on Linux/macOS when files are stored with CRLF + BOM:

  1. CRLF: kernel parses #!/usr/bin/env pwsh\r and tries to find an interpreter named pwsh\r — fails.
  2. BOM: bytes EF BB BF appear before #!, so the kernel doesn't recognize the file as a shebang script at all.

The original "PowerShell uses CRLF for Windows compatibility" rationale predates PowerShell 7+ (cross-platform). The PowerShell team's own canonical repos (PowerShell/PowerShell, PSScriptAnalyzer) all use LF + no BOM.

Changes

File Before After
.gitattributes *.ps1 text eol=crlf *.ps1 text eol=lf
.editorconfig [*.ps1] end_of_line = crlf, charset = utf-8-bom (both removed; LF + utf-8 from [*] defaults)

Comments rewritten to explain the shebang rationale.

What does NOT change

  • Files in the index: already LF. The CRLF rule was aspirational policy that never matched reality. No file content rewrites in this PR.
  • Windows users: core.autocrlf=true (Git for Windows default) still gives CRLF in working tree on checkout. Only the index/wire format is LF.
  • Indent: still 4 spaces for *.ps1.

Note about the protected-files guard

This PR touches .gitattributes (in canonical the rule is in .editorconfig's domain too) and .editorconfig (protected). The Detect .NET Projects guard will fail it. Maintainer override required — same path as the canonical PRs.

Test plan

  • Maintainer override + merge
  • After merge, git ls-files --eol scripts/*.ps1 shows i/lf w/* attr/text eol=lf everywhere

Removes the CRLF + UTF-8-BOM overrides for *.ps1 files in
.gitattributes and .editorconfig. Required for the
'#!/usr/bin/env pwsh' shebang at the top of every script in scripts/
to work as an executable on Linux/macOS.

No file content rewrites — index has been LF the whole time. Only
attr declarations align with reality now.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 10, 2026 00:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Syncs repository formatting policy for PowerShell scripts to use LF (and avoid UTF-8 BOM) so #!/usr/bin/env pwsh scripts can be executed reliably on Linux/macOS, aligning this repo with the canonical template changes.

Changes:

  • Update .gitattributes to normalize *.ps1 files to eol=lf and refresh the rationale comment.
  • Remove *.ps1-specific end_of_line and charset overrides from .editorconfig, relying on global defaults.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.gitattributes Switches *.ps1 EOL attribute from CRLF to LF and updates explanatory comments.
.editorconfig Removes *.ps1 CRLF + UTF-8 BOM overrides, relying on global [*] defaults.

Comment thread .gitattributes Outdated
Comment thread .editorconfig Outdated
Chris-Wolfgang and others added 2 commits May 10, 2026 17:55
Address both Copilot findings on this PR by pulling the latest
.gitattributes and .editorconfig from repo-template (canonical) and
adding the shebang to scripts/Setup-Labels.ps1:

- .gitattributes: replace the comment that incorrectly implied
  core.autocrlf could still give Windows users CRLF when *.ps1 is
  configured with `text eol=lf`. The canonical comment now clearly
  states `eol=lf` forces LF in BOTH the index AND the working tree
  (overriding core.autocrlf). Verified against repo-template main.
- .editorconfig: drop the redundant [*.ps1] section. The global [*]
  section already provides end_of_line = lf, charset = utf-8 (no BOM),
  and indent_size = 4; the per-extension override was a no-op.
- scripts/Setup-Labels.ps1: add `#!/usr/bin/env pwsh` shebang so the
  comment in .gitattributes about "every script in scripts/" is
  factually accurate, and so the script is executable on Linux/macOS.
- Renormalize Setup-Labels.ps1 to LF in the index (it was committed
  with CRLF before *.ps1 was set to `eol=lf`).
- .editorconfig: drop the [*.ps1] section entirely. Its only rule
  (indent_size = 4) was a no-op since the global [*] section already
  sets indent_size = 4. The shebang-rationale comment now sits as a
  top-level note explaining why no override is needed, and is honest
  that the shebang is only present 'where present' rather than in
  'every script in scripts/'.
- .gitattributes: tighten the *.ps1 comment so it doesn't imply that
  `eol=lf` prevents a BOM. Git attributes can only normalize line
  endings; BOM avoidance is enforced via .editorconfig's charset
  setting. Also clarify that `* text=auto eol=lf` (top of file)
  takes precedence over core.autocrlf, so the previous claim about
  Windows users getting CRLF in their working tree was inaccurate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Chris-Wolfgang Chris-Wolfgang merged commit 83c2a05 into main May 14, 2026
7 of 8 checks passed
@Chris-Wolfgang Chris-Wolfgang deleted the chore/sync-ps1-eol-from-canonical branch May 14, 2026 16:49
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.

2 participants