feat: copy .gitignore-d files into new session worktrees - #26
Merged
Conversation
git worktree add only carries tracked files, so ignored artifacts like node_modules/ and .env never appear in a fresh session worktree. This forced each session to reinstall deps and re-create env files before it could build or run. WorktreeManager now copies the repo root's ignored, untracked entries into every new worktree (enabled by default; opt out with the new "copyIgnored": false config key). - ignoredCopyEntries(): pure parser over `git ls-files --others --ignored --exclude-standard --directory` output. `--directory` collapses whole ignored dirs to one entry (node_modules/ stays a single entry instead of tens of thousands of files). Always drops .codiva/ and .git to avoid recursively copying worktrees or corrupting git internals. - WorktreeManager.copyIgnoredFiles(): best-effort fs.cp per entry; a single failure never aborts worktree creation. - config: add copyIgnored (default true) + validation in toConfig(). - docs: README config section + ARCHITECTURE WorktreeManager notes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
セッションを新しく立ち上げるときの git worktree は、git 追跡対象のファイルしか引き継ぎません。そのため
.gitignoreされたnode_modules/や.envなどはコピーされず、各セッションで依存の再インストールや環境変数の再設定が必要でした。この PR で、worktree 作成時にリポジトリルートの ignore された未追跡ファイルを複製するようにします(既定で有効)。
変更点
ignoredCopyEntries()(純関数・新規):git ls-files --others --ignored --exclude-standard --directoryの出力をパースし、コピー対象エントリを返す。--directoryによりディレクトリ全体が ignore されている場合は末尾/付きの1エントリに畳まれる →node_modules/を数万ファイル列挙せず1エントリで扱える。.codiva/(worktree 群を再帰コピーしてしまう)と.git(内部状態破壊)は必ず除外。WorktreeManager.copyIgnoredFiles():fs.cpでエントリ単位のベストエフォート複製。1件の失敗で worktree 作成全体を止めない。add():copyIgnoredが有効なら worktree 作成後にコピーを実行。copyIgnored(既定true)を追加。toConfig()で検証。"copyIgnored": falseで無効化可能。設計判断
ignoredCopyEntriesは純関数、テーブルドリブンでテスト)。--directoryを使い、大量ファイルの列挙を回避。.codiva//.gitを確実に除外。テスト計画
ignoredCopyEntriesの純関数テスト(.codiva/・.git除外、空入力)node_modules/と.envが worktree に複製されることを検証.codiva/が複製されないことを検証copyIgnored: falseで複製がスキップされることを検証toConfig()のcopyIgnored検証(boolean 受理・不正値ドロップ・全キー結合)npm test(479 passed) /npm run typecheck/npm run lint(変更ファイルは警告0)