Skip to content

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

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

chore: sync *.ps1 EOL fix from canonical#196
Chris-Wolfgang merged 2 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:20

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

This PR aligns the repo’s PowerShell script handling with the canonical template by switching *.ps1 files to LF in the Git attributes and removing CRLF/BOM overrides from .editorconfig, to keep #!/usr/bin/env pwsh-style execution working on Linux/macOS.

Changes:

  • Update .gitattributes to set *.ps1 to eol=lf and revise the rationale comments.
  • Remove end_of_line = crlf and charset = utf-8-bom from the [*.ps1] section in .editorconfig, relying on the global defaults.

Reviewed changes

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

File Description
.gitattributes Changes *.ps1 EOL policy to LF and updates explanatory comments.
.editorconfig Removes PowerShell-specific CRLF/BOM overrides and updates rationale comments.

Comment thread .gitattributes
Comment thread .gitattributes
Comment thread .editorconfig
Comment thread .editorconfig
@Chris-Wolfgang Chris-Wolfgang merged commit 0c55c1f into main May 10, 2026
3 of 4 checks passed
@Chris-Wolfgang Chris-Wolfgang deleted the chore/sync-ps1-eol-from-canonical branch May 10, 2026 12:44
Chris-Wolfgang added a commit that referenced this pull request May 12, 2026
PR #196 shipped the LF-EOL switch but its .gitattributes / .editorconfig
wording predated repo-template clarifications, and Copilot flagged four
things that the current canonical now addresses cleanly. This catches
the repo up.

- .gitattributes: canonical clarifies that BOM enforcement is via
  .editorconfig's `charset = utf-8` (not .gitattributes), and that
  `eol=lf` overrides `core.autocrlf` (the previous wording implied the
  reverse). Resolves Copilot threads on .gitattributes:18.
- .editorconfig: canonical drops the redundant `[*.ps1] indent_size = 4`
  block — the global `[*]` already sets `indent_size = 4`. Resolves the
  "indent override is redundant" thread on .editorconfig:35.
- scripts/Setup-Labels.ps1: add the missing `#!/usr/bin/env pwsh`
  shebang. The .editorconfig comment claims a shebang exists at the top
  of every script in scripts/; this script was the only one missing it.
  Resolves the .editorconfig:33 thread.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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