Skip to content

Enforce LF for PowerShell files - #40

Merged
0x0bug merged 3 commits into
mainfrom
ci/enforce-lf-powershell
Jul 26, 2026
Merged

Enforce LF for PowerShell files#40
0x0bug merged 3 commits into
mainfrom
ci/enforce-lf-powershell

Conversation

@0x0bug

@0x0bug 0x0bug commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Why

The supply-chain guarantee for the published bootstrap is a strict byte-for-byte SHA-256 comparison across four copies: scripts/bootstrap/run.ps1 (canonical), wdt-site run.ps1, the Pages artifact, and production https://wdt.digital/run.ps1.

That guarantee currently depends on each contributor's local Git configuration instead of the repository. On Windows with core.autocrlf=true (the Git for Windows default), the working copy of every .ps1 file materializes as CRLF even though all 49 tracked PowerShell blobs are stored as LF. Reproduced measurements:

Copy Bytes SHA-256
Git blob / production 5071 fd1f9bc55fe8665c4a2d4706728eff16723a4c62fffd57baeb9c697b35a77bc6
core.autocrlf=true working copy (before this PR) 5198 ff2f4bf8d5b9a09bf639295c16ff27a341d307c22b5e051ac9064b1940b20afc

Any strict local hash verification against the working copy therefore fails falsely on Windows — the exact platform this toolkit targets.

What changed

  • .gitattributes (new, one rule): *.ps1 text eol=lf. Checkouts of PowerShell files are LF on every platform regardless of core.autocrlf.
  • tests/bootstrap-sync.tests.ps1: regression assertions that the .gitattributes rule exists and is active, that the canonical bootstrap checkout contains no CR bytes, and that its SHA-256 remains the reviewed value (fd1f9bc5…; the pinned value must be updated only for a deliberate bootstrap change).

What did not change

  • git add --renormalize -- ':(glob)**/*.ps1' staged zero content changes: all 49 tracked .ps1 blobs were already LF.
  • Canonical bootstrap content is untouched: blob da249936c88eec0283628ebc4f07d2b94ee3748b, SHA-256 fd1f9bc55fe8665c4a2d4706728eff16723a4c62fffd57baeb9c697b35a77bc6 before and after.

Verification

  • scripts/validate.ps1: pass on PowerShell 7.6.3 and Windows PowerShell 5.1.
  • tests/bootstrap-sync.tests.ps1: pass on both engines; a deliberate CRLF-corruption of the working copy makes the new assertion fail with an actionable message, and git checkout restores LF/fd1f9bc5….
  • tests/release.tests.ps1: pass on both engines.
  • Fresh git clone -c core.autocrlf=true of this branch checks out run.ps1 as LF, 5071 bytes, fd1f9bc5….
  • git diff --check: clean.

🤖 Generated with Claude Code

The published bootstrap contract is a byte-for-byte SHA-256 comparison
between scripts/bootstrap/run.ps1, the wdt-site copy, and production.
Without a repository-owned EOL policy, Windows checkouts with
core.autocrlf=true materialize CRLF working copies (5198 bytes,
sha256 ff2f4bf8...) while the Git blob and production stay LF
(5071 bytes, sha256 fd1f9bc5...), so strict local hash checks fail
falsely.

- Add .gitattributes with the single rule '*.ps1 text eol=lf'.
- Renormalization of tracked .ps1 files is a no-op: all 49 blobs are
  already stored as LF, and the canonical bootstrap blob
  (da24993) is unchanged.
- Extend tests/bootstrap-sync.tests.ps1 to pin the policy: the
  .gitattributes rule must exist, the bootstrap checkout must contain
  no CR bytes, and its SHA-256 must remain the reviewed value.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@0x0bug
0x0bug marked this pull request as ready for review July 26, 2026 13:55
@0x0bug 0x0bug closed this Jul 26, 2026
@0x0bug 0x0bug reopened this Jul 26, 2026
@0x0bug
0x0bug merged commit 753dd51 into main Jul 26, 2026
1 check passed
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