Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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
go.mod text eol=lf
go.sum text eol=lf

# Go templates and golden test data — template output is LF;
# byte-for-byte golden comparisons break if checked out as CRLF.
*.tmpl text eol=lf
cli/testdata/**/*.yml text eol=lf

# Shell scripts must use LF (bash can't parse CRLF).
*.sh text eol=lf
Comment on lines +1 to +14
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.

medium

This is a good start for ensuring consistent line endings. To make it more comprehensive, I suggest a few additions:

  1. 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.
  2. Include go.mod and go.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.
  3. 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


# Dockerfiles run in Linux containers — CRLF breaks shell continuations and heredocs.
Dockerfile text eol=lf

# PowerShell scripts — Windows expects CRLF.
*.ps1 text eol=crlf
Loading