fix: add .gitattributes to enforce LF line endings for Go files#483
fix: add .gitattributes to enforce LF line endings for Go files#483
Conversation
core.autocrlf=true on Windows converts LF→CRLF on checkout, causing golangci-lint gofmt checks to fail with spurious "not properly formatted" errors. Worktrees are worst affected since every file gets a fresh checkout. Force *.go and *.sh to always use LF in the working tree regardless of the user's autocrlf setting.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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 introduces a 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: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2026-03-15T11:48:14.867ZApplied to files:
🔇 Additional comments (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a new Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Code Review
This pull request adds a .gitattributes file to enforce LF line endings for Go and shell script files. My review includes a suggestion to expand this configuration to cover other relevant file types (go.mod, go.sum, .ps1) and to set a recommended default for all text files, making the approach more robust.
| # Go tooling (gofmt, golangci-lint) requires LF line endings. | ||
| # Without this, core.autocrlf=true on Windows converts to CRLF on checkout, | ||
| # causing spurious "not properly formatted" errors — especially in worktrees. | ||
| *.go text eol=lf | ||
|
|
||
| # Shell scripts must use LF (bash can't parse CRLF). | ||
| *.sh text eol=lf |
There was a problem hiding this comment.
This is a good start for ensuring consistent line endings. To make it more comprehensive, I suggest a few additions:
- Add
* text=auto: This is a recommended best practice. It tells Git to automatically handle line endings for any file it detects as text, which prevents files from being accidentally treated as binary. - Include
go.modandgo.sum: These files are also managed by Go tooling and can cause issues if they have inconsistent line endings. It's best to enforce LF for them as well. - Include
*.ps1: For consistency with other scripts (.sh), it's a good idea to enforce LF for PowerShell scripts too.
Here is a suggested update that incorporates these points.
# Auto-detect text files and normalize line endings.
* text=auto
# Enforce LF for Go-related files.
*.go text eol=lf
go.mod text eol=lf
go.sum text eol=lf
# Enforce LF for scripts.
*.sh text eol=lf
*.ps1 text eol=lf
…olden tests Address review feedback from infra-reviewer, Gemini, and CodeRabbit: - Add Dockerfile LF rule (CRLF breaks shell continuations in Linux containers) - Add *.tmpl and cli/testdata/**/*.yml LF rules (golden test comparisons) - Add go.mod/go.sum LF rules (Go tooling consistency) - Add *.ps1 CRLF rule (PowerShell expects CRLF on Windows)
🤖 I have created a release *beep* *boop* --- ## [0.2.8](v0.2.7...v0.2.8) (2026-03-16) ### Features * add RRF rank fusion to memory ranking ([#478](#478)) ([42242b5](42242b5)) * collaboration scoring enhancements — LLM sampling and human override ([#477](#477)) ([b3f3330](b3f3330)) ### Bug Fixes * add .gitattributes to enforce LF line endings for Go files ([#483](#483)) ([1b8c7b6](1b8c7b6)) * **cli:** Windows uninstall, update UX, health check, sigstore ([#476](#476)) ([470ca72](470ca72)) ### Refactoring * **web:** extract WebSocket subscription into reusable composable ([#475](#475)) ([96e6c46](96e6c46)), closes [#351](#351) ### Maintenance * bump hypothesis from 6.151.5 to 6.151.9 in the minor-and-patch group ([#482](#482)) ([a7297d5](a7297d5)) * bump nginxinc/nginx-unprivileged from `aec540f` to `ccbac1a` in /docker/web ([#479](#479)) ([176e052](176e052)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
.gitattributesto force*.goand*.shfiles to use LF line endings in the working tree, regardless ofcore.autocrlfsettinggolangci-lintgofmt failures on Windows (especially in worktrees) caused by CRLF conversionRoot Cause
core.autocrlf=true(Windows default) converts LF→CRLF on checkout. Go tooling (gofmt/golangci-lint) treats CRLF as a formatting error. Worktrees are worst affected since every file gets a fresh checkout — all 22 Go files with CRLF were flagged.Test plan
golangci-lint runpasses (0 issues) after applying.gitattributesgofmt -l .reports no filesw/lfingit ls-files --eoloutput