Skip to content

chore: keep the working copy LF on every platform - #64

Merged
kukv merged 1 commit into
mainfrom
chore/gitattributes-go-eol
Sep 7, 2026
Merged

chore: keep the working copy LF on every platform#64
kukv merged 1 commit into
mainfrom
chore/gitattributes-go-eol

Conversation

@kukv

@kukv kukv commented Sep 7, 2026

Copy link
Copy Markdown
Owner

なぜ

Windows で core.autocrlf=true のままチェックアウトすると、.golden 以外の全ファイルが CRLF になる。実測した影響は次のとおり。

.go(94 ファイル)— 実害あり。 gofumpt は CRLF を「整形されていない」と判定するため、make lintmake fmt-check が全ファイルで落ちる。

internal/usecase/usecase.go:1:1: File is not properly formatted (gofumpt)
...
93 issues:
* gofumpt: 93

make fmt を毎回挟めば回避できるが、git checkoutgit stash のたび再発する。

.sh(2 ファイル)— 壊れうる。 .claude/hooks/ の PreToolUse フック。CRLF のシェルスクリプトは $'\r': command not found を起こす。現状は落ちなかったが、read やヒアドキュメントが入れば壊れる。静かに動かなくなる種類のもの。

testdata(15 ファイル)— 潜在的。 現在 883 テストは CRLF のまま通っており、パーサは改行に寛容。ただしこれは偶然で、行分割に敏感な処理が入ると「ローカルは通るが CI は落ちる」形で出る。

何をしたか

作業コピーを全プラットフォームで LF に固定し、バイト比較が要るものだけ例外にした。

* text=auto eol=lf

*.golden -text

internal/gh/cli/testdata/** -text

text=auto はバイナリを自動判別するので LICENSE などに影響しない。.gitattributes は後の行が勝つため、-text の 2 つが例外として効く。

internal/gh/cli/testdata/**-text にしたのは、これが GitHub から録ったレスポンスそのものだから。改行を変換するのは「録ったファイルの編集」にあたる(.claude/rules/testing.md)。.golden-text にしているのと同じ理屈。

インデックスは元から全て LF なので、この PR の差分は .gitattributes の 11 行だけで、既存ファイルは 1 バイトも変わっていない。

確認

  • 作業ツリーを再チェックアウトし、.golden 以外に CRLF が 0 件
  • もう一度再チェックアウトしても git status が clean(べき等)
  • make fmt を挟まずに make check が終了コード 0

CI(Linux)は元から LF なので挙動は変わらない。効くのは Windows のチェックアウトだけ。

🤖 Generated with Claude Code

@github-actions

This comment has been minimized.

gofumpt treats a CRLF file as unformatted. On a Windows checkout with
core.autocrlf=true that is every Go file in the repository, so `make
lint` and `make fmt-check` fail with 93 issues that have nothing to do
with the code, and `make fmt` has to be re-run after every checkout.

The index is already LF -- renormalizing changes no content -- so this
only pins what a checkout writes to disk.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kukv kukv changed the title chore: keep Go sources LF in the working copy chore: keep the working copy LF on every platform Sep 7, 2026
@kukv
kukv force-pushed the chore/gitattributes-go-eol branch from 6ff680e to 1d03791 Compare September 7, 2026 21:58
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Code Metrics Report

Coverage Test Execution Time
87.2% 40s

Reported by octocov

@kukv
kukv merged commit 00b492c into main Sep 7, 2026
3 checks passed
@kukv
kukv deleted the chore/gitattributes-go-eol branch September 7, 2026 22:15
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.

1 participant