fix: enforce LF line endings for PowerShell files (#1081)#1092
fix: enforce LF line endings for PowerShell files (#1081)#1092
Conversation
Pre-push hook failed because Scan-TodoComments.ps1 had CRLF line endings. PowerShell block comment terminators (#>) include a trailing \r under CRLF, causing parse failures from Git Bash and Unix shells. Add *.ps1, *.psm1, *.psd1 with text eol=lf to .gitattributes and a corresponding editorconfig section. Document the decision in ADR-010. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug where pre-push hooks failed due to PowerShell parse errors caused by CRLF line endings in scripts when run in non-Windows environments. By enforcing LF line endings for all PowerShell files via Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds PowerShell-specific eol and formatting rules to Changes
Sequence Diagram(s)(omitted — changes are configuration/docs and a small hook data-structure adjustment; no new multi-component control flow requiring visualization) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| C# | Apr 5, 2026 4:52a.m. | Review ↗ |
There was a problem hiding this comment.
Code Review
This pull request correctly enforces LF line endings for PowerShell scripts by updating .gitattributes and .editorconfig. It also introduces a well-documented Architecture Decision Record (ADR-010) to explain the rationale. My review focuses on ensuring consistency within the new ADR and its corresponding index entry. I've identified a few minor issues: inconsistent status metadata, a future date in the ADR, and a planned documentation update to CONTRIBUTING.md that appears to be missing from this PR.
| | ADR-007 | Prefer RegisterOperationAction Over RegisterSyntaxNodeAction | Accepted | | ||
| | ADR-008 | BenchmarkDotNet and PerfDiff for Performance Regression Detection | Accepted | | ||
| | ADR-009 | xUnit with Roslyn Test Infrastructure | Accepted | | ||
| | ADR-010 | Use eol=lf for PowerShell Files in .gitattributes | Proposed | |
There was a problem hiding this comment.
The status for ADR-010 is Proposed, which is inconsistent with the ADR's frontmatter status of Accepted. Since this PR implements the decision, this should be updated to Accepted for consistency.
| | ADR-010 | Use eol=lf for PowerShell Files in .gitattributes | Proposed | | |
| | ADR-010 | Use eol=lf for PowerShell Files in .gitattributes | Accepted | |
|
|
||
| - **IMP-001**: Add the three glob rules (`*.ps1`, `*.psm1`, `*.psd1`) to `.gitattributes` in the file-type section alongside existing extension-based rules. | ||
| - **IMP-001a**: Add a corresponding `[*.{ps1,psm1,psd1}]` section to `.editorconfig` with `end_of_line = lf` so editors enforce LF on save, preventing CRLF from being introduced during editing. | ||
| - **IMP-002**: After pulling the merged fix, contributors should run `git add --renormalize . && git checkout .` to apply the new line ending rules. Alternatively, a fresh clone applies the rules automatically. Document this in the PR description and CONTRIBUTING.md. |
There was a problem hiding this comment.
This implementation note states that CONTRIBUTING.md should be updated to include the git add --renormalize . command for existing contributors. However, CONTRIBUTING.md was not modified in this pull request. Please either update the file as planned or remove this part of the implementation note if it's intended to be handled separately.
There was a problem hiding this comment.
Pull request overview
This PR fixes a pre-push hook failure (#1081) caused by CRLF line endings in PowerShell scripts breaking block comment parsing when invoked from Git Bash or Unix shells. The fix enforces LF line endings for all PowerShell files via .gitattributes and .editorconfig, and documents the decision in a new ADR.
Changes:
- Add
*.ps1,*.psm1,*.psd1withtext eol=lfto.gitattributesand a matchingend_of_line = lfsection to.editorconfig - Add ADR-010 documenting the rationale, alternatives, and trade-offs for this line-ending policy
- Update the Serena memory index with the new ADR entry
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.gitattributes |
Adds LF line ending enforcement for PowerShell file extensions |
.editorconfig |
Adds PowerShell section with end_of_line = lf and formatting defaults |
docs/architecture/ADR-010-eol-lf-for-powershell-files.md |
New ADR documenting the decision to use LF for PowerShell files |
.serena/memories/architecture-decision-records.md |
Adds ADR-010 to the memory index |
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| ## Status | ||
|
|
||
| Proposed |
| | ADR-007 | Prefer RegisterOperationAction Over RegisterSyntaxNodeAction | Accepted | | ||
| | ADR-008 | BenchmarkDotNet and PerfDiff for Performance Regression Detection | Accepted | | ||
| | ADR-009 | xUnit with Roslyn Test Infrastructure | Accepted | | ||
| | ADR-010 | Use eol=lf for PowerShell Files in .gitattributes | Proposed | |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
The ADR body and Serena memory index both said "Proposed" while the frontmatter said "Accepted". Align all three to Accepted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
This smells fishy to me? If the script uses [Environment]::NewLine it should do the right thing on each platform. I think we're already normalizing to store lf. That said, I also don't think this breaks anything, I just think forcing lf is working around some other issue rather than fixing the root issue. If I'm misunderstanding though, please let me know! |
PowerShell ForEach-Object returns a scalar string when the pipeline produces one element. Splatting a string with @variable passes each character as a separate argument, causing markdownlint-cli2 to hang at 100% CPU. Wrap all ForEach-Object pipelines in @() to force array context. Affects md, yaml, workflow, shell, and cs file collections. Also removes stale CONTRIBUTING.md reference from ADR-010 IMP-002. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This is only failing on Ubuntu when running the git hooks. Will like be fixed with #1097 |
|
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.00% coverage variation (-1.00%) |
| Diff coverage | ✅ ∅ diff coverage (95.00%) |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (2dbd090) 2660 2391 89.89% Head commit (681b435) 2660 (+0) 2391 (+0) 89.89% (+0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#1092) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
TIP This summary will be updated as you push new changes. Give us feedback
Description
Pre-push hook fails with a PowerShell parse error in
Scan-TodoComments.ps1, blocking all pushes. The<# ... #>block comment terminator includes a trailing\runder CRLF, which PowerShell cannot parse when invoked from Git Bash or Unix shells.Fixes #1081
Motivation and Context
All pushes were blocked unless bypassed with
--no-verify. The.gitattributesenforcedeol=lffor.githooks/**but PowerShell scripts underbuild/scripts/inheritedtext=auto, producing CRLF on Windows checkouts.Changes Made
*.ps1,*.psm1,*.psd1withtext eol=lfto.gitattributes(Scripts section)[*.{ps1,psm1,psd1}]section to.editorconfigwithend_of_line = lfType of Change
Checklist
CONTRIBUTING.mdPost-Merge Action
Contributors with existing checkouts should run:
Or perform a fresh clone. This applies the new LF line ending rules to locally cached CRLF copies.
Summary by CodeRabbit
Chores
Documentation