Skip to content

feat(create): inherit mise.toml and mise.local.toml into worktrees - #16

Merged
nanasess merged 2 commits into
mainfrom
issue-12
Apr 21, 2026
Merged

feat(create): inherit mise.toml and mise.local.toml into worktrees#16
nanasess merged 2 commits into
mainfrom
issue-12

Conversation

@nanasess

@nanasess nanasess commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Copy mise.toml / mise.local.toml from the source project into each new worktree during worktree create
  • Works for both single-repo (project root) and multi-repo (per sub-repo root) layouts
  • Preserves tracked mise.toml already checked out by git worktree add (skips copy when destination exists)

Motivation

mise-managed tool versions (PHP, Node.js, .NET, ...) did not follow new worktrees when the config was gitignored — mise.local.toml in particular is conventionally local-only, and git worktree add only checks out tracked files. As a result, worktrees fell back to global/system versions and subsequent npm install / composer install / dotnet restore could run under the wrong toolchain.

Changes

  • lib/common.sh: add copy_mise_configs helper (iterates over mise.toml, mise.local.toml, skips if destination exists)
  • lib/cmd_create.sh: invoke the helper for each created worktree before the .worktreerc hook
  • test/single_repo.bats: verify untracked mise.toml and mise.local.toml are copied
  • test/multi_repo.bats: verify untracked mise.local.toml is copied per sub-repo (uses mise.local.toml only since some upstream sub-repos already track mise.toml)
  • README.md / CLAUDE.md / skills/worktree-create/SKILL.md: document the new step

Test plan

  • ./test/bats/bin/bats test/*.bats — 27/27 passing
  • Single-repo: untracked mise.toml + mise.local.toml copied with matching content
  • Multi-repo: untracked mise.local.toml copied into each sub-repo worktree
  • Tracked mise.toml provided by git worktree add is preserved (copy skipped)

Refs: #12

🤖 Generated with Claude Code

Summary by CodeRabbit

リリースノート

  • 新機能

    • worktree作成時にmise設定ファイルが自動的に新worktreeにコピーされるようになりました。プロジェクトルートまたは各サブリポルートから設定が継承され、ツールバージョンの統一が保たれます。
  • ドキュメント

    • mise設定ファイル継承動作についてドキュメントを拡充しました。
  • テスト

    • mise設定継承機能の動作確認テストを追加しました。

Copy `mise.toml` and `mise.local.toml` from the source project into
each new worktree when running `worktree create`. For single-repo
projects the files are copied from the project root; for multi-repo
projects they are copied from each sub-repo root.

This lets mise-managed tool version pinning (PHP, Node.js, .NET, etc.)
follow the worktree even when the config is gitignored (`mise.local.toml`
is the common case). Copies are skipped when the destination already
has the file, so tracked `mise.toml` provided by `git worktree add`
is preserved.

Refs: #12

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@nanasess has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 57 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 57 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9be3722b-72f6-44d7-ba61-e5118f8fa3bb

📥 Commits

Reviewing files that changed from the base of the PR and between b6e9c2d and 1d345aa.

📒 Files selected for processing (1)
  • lib/common.sh
📝 Walkthrough

Walkthrough

worktree 作成時に mise.tomlmise.local.toml をコピーする機能を追加。ドキュメント 4 ファイルを更新し、ヘルパー関数と実装コードを追加し、単一リポと複数リポのテストケースを新規作成。

Changes

Cohort / File(s) Summary
ドキュメント更新
CLAUDE.md, README.md, skills/worktree-create/SKILL.md
mise 設定の引き継ぎ機能をドキュメント化。worktree create が mise.toml/mise.local.toml をコピーする挙動と実行順序(copy 後に .worktreerc hook 実行)を明記。
実装追加
lib/cmd_create.sh, lib/common.sh
copy_mise_configs ヘルパー関数を lib/common.sh に追加し、lib/cmd_create.sh の worktree 作成後処理で各リポの mise 設定をコピー。宛先に既に同名ファイルがあれば skip。
テスト追加
test/single_repo.bats, test/multi_repo.bats
単一リポ版と複数リポ版それぞれで mise.toml/mise.local.toml のコピー動作を検証。作成・確認・クリーンアップの一連の流れをテスト化。

Sequence Diagram

sequenceDiagram
    participant User
    participant cmd_create as lib/cmd_create.sh
    participant repo as Repository
    participant copy as copy_mise_configs
    participant hook as .worktreerc hook
    participant deps as Dependency Install

    User->>cmd_create: worktree create
    cmd_create->>repo: Create worktree directory
    cmd_create->>cmd_create: Add repo to created_repos list
    
    loop For each created repo
        cmd_create->>copy: copy_mise_configs(src, dest)
        copy->>repo: Copy mise.toml (if exists & !exists in dest)
        copy->>repo: Copy mise.local.toml (if exists & !exists in dest)
    end
    
    cmd_create->>hook: Execute .worktreerc post_create()
    hook->>repo: Run post-creation tasks
    cmd_create->>deps: Auto-install dependencies
    deps->>repo: Install tools based on copied mise configs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Worktree の新枝へ、
mise の設定をそっと移す、
バージョン揃えて皆笑顔 ✨
うさぎのお手伝い 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、主な変更内容(mise.tomlmise.local.tomlをワークツリーに継承する機能)を明確かつ簡潔に要約している。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-12

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements mise configuration inheritance when creating new worktrees. It ensures that mise.toml and mise.local.toml files are copied from the source to the new worktree, allowing tool version pinning to persist even for gitignored files. Documentation and tests for both single-repo and multi-repo setups have been updated accordingly. Feedback was provided regarding the error handling of the file copy operation in lib/common.sh to ensure logs accurately reflect whether the copy succeeded.

Comment thread lib/common.sh Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/single_repo.bats (1)

114-117: コピーであることも検証してください。

[ -f ]diff は symlink を追跡するため、実体コピーではなく symlink でもこのテストは通ります。copy_mise_configs の仕様を守るなら -L で symlink でないことも確認してください。

修正案
     [ -f "${WORKTREES_DIR}/mise-task/mise.toml" ]
     [ -f "${WORKTREES_DIR}/mise-task/mise.local.toml" ]
+    [ ! -L "${WORKTREES_DIR}/mise-task/mise.toml" ]
+    [ ! -L "${WORKTREES_DIR}/mise-task/mise.local.toml" ]
     diff "${SINGLE_REPO_DIR}/mise.toml" "${WORKTREES_DIR}/mise-task/mise.toml"
     diff "${SINGLE_REPO_DIR}/mise.local.toml" "${WORKTREES_DIR}/mise-task/mise.local.toml"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/single_repo.bats` around lines 114 - 117,
テストがシンボリックリンクでも通ってしまうため、single_repo.bats の該当アサーションを強化して copy_mise_configs
が実体コピーを作っていることを確認してください。具体的には既存の [ -f "${WORKTREES_DIR}/mise-task/mise.toml" ] と
diff コマンドに加えて [ ! -L "${WORKTREES_DIR}/mise-task/mise.toml" ] と [ ! -L
"${WORKTREES_DIR}/mise-task/mise.local.toml" ]
のチェックを追加し、両ファイルがシンボリックリンクでないことを検証してください(対象を見つける目印は copy_mise_configs
と該当のファイルパス)。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CLAUDE.md`:
- Around line 37-41: Replace English words used inside normal sentences with
Japanese equivalents in CLAUDE.md: change instances of "tracked" and "skip" to
appropriate Japanese terms (e.g., "追跡済み" and "スキップ" or better Japanese phrasing)
and ensure the whole paragraph for `worktree create` and the bullet points use
Japanese-only wording while keeping references to filenames (`mise.toml` /
`mise.local.toml`) and command `worktree create` unchanged; preserve the meaning
about copying files, the single-repo vs multi-repo rules, and the skip behavior
when files already exist in the worktree.

In `@lib/common.sh`:
- Around line 115-118: The current block calls cp "$src_file" "$dst_file" then
unconditionally logs via log_info "  ${name} -> copied (from ${src_file})" even
if cp failed; change the flow in the snippet that references "$src_file",
"$dst_file", and log_info so that you check cp's exit status (e.g., run cp and
test its return or use if cp ...; then ...) and only call log_info on success,
and on failure return a non‑zero status (propagate the error) so the caller sees
the failure and can handle it.

---

Nitpick comments:
In `@test/single_repo.bats`:
- Around line 114-117: テストがシンボリックリンクでも通ってしまうため、single_repo.bats の該当アサーションを強化して
copy_mise_configs が実体コピーを作っていることを確認してください。具体的には既存の [ -f
"${WORKTREES_DIR}/mise-task/mise.toml" ] と diff コマンドに加えて [ ! -L
"${WORKTREES_DIR}/mise-task/mise.toml" ] と [ ! -L
"${WORKTREES_DIR}/mise-task/mise.local.toml" ]
のチェックを追加し、両ファイルがシンボリックリンクでないことを検証してください(対象を見つける目印は copy_mise_configs
と該当のファイルパス)。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbc11be8-367c-406b-a6fe-7e6fa82c358c

📥 Commits

Reviewing files that changed from the base of the PR and between da0f253 and b6e9c2d.

📒 Files selected for processing (7)
  • CLAUDE.md
  • README.md
  • lib/cmd_create.sh
  • lib/common.sh
  • skills/worktree-create/SKILL.md
  • test/multi_repo.bats
  • test/single_repo.bats

Comment thread CLAUDE.md
Comment thread lib/common.sh
Check the exit status of `cp` and emit a `log_warn` on failure so the
log no longer claims "copied" when the destination could not be
written (e.g. permission error, disk full). Matches the
`(continuing)` warning style already used for `git fetch` and
dependency install steps.

Co-Authored-By: Claude <noreply@anthropic.com>
@nanasess
nanasess merged commit bf4a524 into main Apr 21, 2026
3 checks passed
@nanasess
nanasess deleted the issue-12 branch April 21, 2026 02:33
@nanasess nanasess mentioned this pull request Apr 21, 2026
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