feat(cli): auto-seed git worktrees from their base checkout#747
Merged
Conversation
repowise init and repowise update inside a linked worktree now detect the base checkout via git rev-parse --git-common-dir and seed the worktree's index from it automatically, then catch up incrementally. --seed-from becomes an explicit override; --no-seed forces a cold init. The seed logic moves from init_cmd into a shared cli/worktree.py used by both commands, and gains a repository-identity adoption step: the copied wiki.db row is re-pointed (name + local_path) at the worktree, since upsert_repository matches by local_path and the first update otherwise minted a second repository row and split the index in two. Also fixes the workspace auto-detect notice, whose [workspace] prefix was silently consumed as console markup, and repairs the #655 seed tests, which were red on main CI (raw git commits without identity) and on Windows (default-branch assumption, unclosed sqlite handles breaking worktree cleanup, REPOWISE_DB_URL fixture routing both repos into one db, line-wrapped substring assertions). The new-file page assertion is dropped: update-time coverage budgeting prevents it repo-wide (#746). Docs: new WORKTREES.md, WORKSPACES FAQ, CLI_REFERENCE, README, QUICKSTART, changelogs.
|
✅ Health: 7.7 (unchanged) 📋 At a glance Files & modules (2)
🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔎 More signals (3)🔥 Hotspots touched (4)
1 more
🔗 Hidden coupling (3 files)
💀 Dead code (2 findings)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-10 10:32 UTC |
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.
What
Makes git worktrees seamless:
repowise initandrepowise updateinside a linked worktree now detect the base checkout automatically (viagit rev-parse --git-common-dir), seed the worktree's index from it, and catch up incrementally. No flags, no paths. Follow-up to #655, which introduced the manual--seed-fromflag.--seed-from <path>stays as an explicit override for unusual layouts--no-seedforces a cold init inside a worktreeupdateauto-seeding means post-commit hooks and coding agents running in a fresh worktree get the fast path with zero setupBug fixes along the way
Seeded indexes no longer split in two.
upsert_repositorymatches bylocal_path, so a seeded wiki.db still pointed at the base checkout; the first update in the worktree minted a second repository row named after the worktree dir and regenerated everything under it, while the seeded pages stayed orphaned under the old row (breaking prior-page reuse and repo-scoped queries). Seeding now adopts the copied row: name andlocal_pathare re-pointed at the worktree and the repo-level pages are retargeted.[workspace]notices render again.[dim][workspace][/dim]was being parsed as console markup and printed without its prefix. Both the workspace notice and the new[worktree]notice are escaped.The #655 test suite is green again. The seed tests were failing on main's CI (integration tests only run on push to main, so the PR run never exercised them) and failed differently on Windows:
git commitcalls without identity env (exit 128 on CI runners); now routed through the identity-injecting_githelpergit checkout mainassumed the default branch name; now captured viarev-parsewith sqlite3.connect(...)never closes the handle, which broke worktree cleanup on Windows; replaced with closed-connection helpersgit_work_repofixture pinsREPOWISE_DB_URLto the base repo's db, silently routing the worktree's delegated update into the wrong database; the seed tests now drop the env var and use repo-local DBsrmtreebeforegit worktree remove) left git bookkeeping pointing at a missing dirThe index-only survival assertion moved from
wiki_pages(empty in index-only runs) tograph_nodes, and the "new file gets a page" assertion is dropped: update-time coverage budgeting prevents it on every platform, tracked as #746.Docs
New
docs/WORKTREES.md(behavior, skip conditions, overrides, troubleshooting); WORKSPACES FAQ, CLI_REFERENCE, README, and QUICKSTART updated; changelog entries added under Unreleased (and the #655 entry moved out of the 0.25.0 section it had landed in).Testing
--no-seed, update auto-seed, unindexed-base fallback) plus the 5 repaired feat(cli): allow seeding worktree index from base branch #655 teststests/integration/test_cli.py(28) andtests/unit/cli+tests/unit/workspace(1162) green on Windows; end-to-end verified manually with the mock provider (single repository row, seeded pages reused, state advanced to worktree HEAD)