feat(cli): allow seeding worktree index from base branch#655
Conversation
|
✅ 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 (2)🔥 Hotspots touched (5)
2 more
🔗 Hidden coupling (2 files)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-10 09:27 UTC |
|
Thanks for this, the overall shape is right and the fallback validation reads well. A few things before it can go in, the first two are the blockers.
The seed builds a temp dir with just those two files and renames it over .repowise/. What gets dropped:
Easiest fix is to copy the whole .repowise/ tree rather than cherry-picking two files. If you want to be selective, at least add lancedb/, config.yaml, and health-rules.json to the list.
Small stuff: run_update is called with progress, verbose, and no_cost_tracking hardcoded, so a scripted seed can't get JSON progress. And --include-submodules from the seeding init is silently overridden by the copied state, worth a warning if they don't match. Happy to re-review once 1 and 2 are in. |
|
All blocker and non-blocking feedback addressed. Switched to shutil.copytree for the full .repowise/ tree (lancedb, config.yaml, health-rules.json all carry over), removed the config_fingerprint pop since config.yaml is now copied atomically (avoids unnecessary rescore), added all four doc locations, relocated the bak sweep inside the seed branch, wired through the progress/verbose/no-cost-tracking flags, and added the include-submodules conflict warning. Happy-path test now asserts unchanged pages survived in SQLite; also added a provider test case covering config and lancedb carry-over. |
|
The red CI is the actual blocker. The failing test across all 3 Python versions is test_update_command_uses_editor_refresh_abstraction. It does inspect.getsource(update_command.callback) and asserts "refresh_editor_project_files" is in there. Since you extracted the body into run_update() and left the callback as a thin wrapper, that string now lives in run_update, not the callback, so the assert fails. The refactor is fine, the guard test just needs to point at run_update instead. Mind updating it? The other failure (test_add_fourth_repo_round_trip) only shows on 3.13 with a GeneratorExit error, which looks like a flake from async teardown. Since this PR touches scanner.py though, worth a re-run to confirm it's not the _is_submodule change. |
|
Updated test_update_command_uses_editor_refresh_abstraction to inspect run_update directly instead of update_command.callback, since that's where the logic lives after the refactor. Passes locally across all versions. |
|
The single-repo path reuses the existing
Smaller items. |
|
This is great, thanks for working on it everyone! I'm gonna try it out. |
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.
|
Thanks for the review and the merge, @RaghavChamadiya, @vrajpal-jhala and @swati510! @swati510 I saw your feedback regarding the --dry-run bypass. Since this is already merged, I'd love to open a quick follow-up PR to address those exact edge cases so we don't leave any technical debt behind. |
Summary
--seed-from <base-checkout-path>flag torepowise initto allow seeding a worktree index from a base branch, skipping expensive full re-indexes for heavily overlapping codebase states..repowise/state and database securely, incorporating safe fallbacks to full initializations upon invalid ancestry paths or mismatched repositories.run_update()fromupdate_cmdinto a reusable module for seamless incremental update delegation, and fixes a scanner bug where git worktrees were misclassified as submodules.Related Issues
Fixes #518
Test Plan
Added integration test suite
TestInitSeedFromcovering the valid "slightly stale but valid base" case as well as unreachable/unrelated base fallback rejections.Added unit test coverage for
_is_submoduleintest_scanner.py.Tests pass (
pytest)Lint passes (
ruff check .)Web build passes (
npm run build) (if frontend changes)Checklist