Skip to content

fix(tool): detect repo root from a linked worktree in build_skill_assets - #113

Open
dipsy wants to merge 1 commit into
Arenukvern:mainfrom
dipsy:fix/skill-assets-worktree-root
Open

fix(tool): detect repo root from a linked worktree in build_skill_assets#113
dipsy wants to merge 1 commit into
Arenukvern:mainfrom
dipsy:fix/skill-assets-worktree-root

Conversation

@dipsy

@dipsy dipsy commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem

_findRepoRoot() in mcp_server_dart/tool/build_skill_assets.dart walks up from the current directory looking for a .git directory. In a linked worktree (git worktree add) — and in a submodule checkout — .git is a file holding a gitdir: pointer, so the walk runs past the repo root and the tool aborts:

Unhandled exception:
Bad state: Not in a git repo
#0      _findRepoRoot (.../mcp_server_dart/tool/build_skill_assets.dart:138:3)
#1      main (.../mcp_server_dart/tool/build_skill_assets.dart:30:20)
make: *** [sync-skills] Error 255

sync-skills is a prerequisite of compile, so make compile cannot run from a worktree at all. That is a normal setup when validating a PR branch side by side with a working checkout.

Change

Accept both shapes of the marker — a .git directory or a .git file. Plain clones still match the directory check first, so their behaviour is unchanged.

Verification

From a linked worktree, all previously failing paths now succeed and regenerate skill_assets.g.dart byte-identically to the committed file:

  • make sync-skills in mcp_server_dart/ — the exact command that failed above;
  • dart run mcp_server_dart/tool/build_skill_assets.dart from the worktree root and from a nested package directory;
  • bash tool/contracts/check_skill_assets_drift.shskill_assets.g.dart in sync with plugin/;
  • git status after the runs shows no drift beyond the tool file itself.

Summary by CodeRabbit

  • Bug Fixes
    • Improved repository detection across standard checkouts, linked worktrees, and submodules.
    • Build asset discovery now works when Git metadata is represented by either a directory or a file.

_findRepoRoot walked up looking for a `.git` directory, which only exists
in a plain clone. In a linked worktree (and in a submodule checkout) `.git`
is a file holding a `gitdir:` pointer, so the walk ran past the repo root
and the tool aborted with "Bad state: Not in a git repo" — taking down
`make sync-skills`, and with it `make compile`, for anyone building from a
worktree.

Accept both shapes of the marker. Plain clones keep hitting the directory
check first, so their behaviour is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 31821852-71cd-4fca-962a-4a761553d620

📥 Commits

Reviewing files that changed from the base of the PR and between 6975f88 and 3ea5433.

📒 Files selected for processing (1)
  • mcp_server_dart/tool/build_skill_assets.dart

📝 Walkthrough

Walkthrough

Changes

Repository root detection

Layer / File(s) Summary
Support file-based Git markers
mcp_server_dart/tool/build_skill_assets.dart
_findRepoRoot() now recognizes both .git directories and .git files for standard clones, linked worktrees, and submodules.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: arenukvern

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: improving repo-root detection for build_skill_assets in linked worktrees.
Description check ✅ Passed The description covers the problem, change, and verification, but it does not follow the template's exact Summary/Validation/Checklist/Notes headings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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