Expand description
vcs-core — a unified facade over vcs-git and vcs-jj.
Two pieces both downstream tools kept re-implementing:
detect— walk up from a directory to find a.git/.jjrepository (jj wins when colocated), returning theBackendKindand root.Repo— a cwd-bound handle that dispatches the common VCS operations (status, diff stat, partial commit, worktree create/remove, …) to whichever backend is present, returning backend-agnostic DTOs. Open it once withRepo::open; re-anchor it to another directory withRepo::atwithout threading adirargument through every call.
Tool-specific operations stay on the underlying typed clients, reachable via
the cwd-bound Repo::git_at / Repo::jj_at handles (or the raw
Repo::git / Repo::jj escape hatches). Some operations are deliberately
not on the common surface because the backends model them too differently to
unify without lying: a full merge (jj composes new + squash + bookmark
moves), operation rollback (jj’s op restore has no faithful git analogue),
and range/revset-scoped queries (commit_count, diff stats over a range —
git’s a..b and jj’s revsets aren’t interchangeable). Reach those through the
bound handles.
use vcs_core::Repo;
let repo = Repo::open(".")?;The handle is generic over the ProcessRunner so tests can inject a fake;
Repo::open uses the real job-backed runner.
Re-exports§
Structs§
- Diff
Stat - Aggregate insertion/deletion counts for the working copy.
- File
Change - One changed path in the working copy, unified across
git status/jj diff --summary. - Located
- The result of
detect: which backend, and the repository root it was found at. - Repo
- A cwd-bound, backend-agnostic VCS handle. Operations run against the bound
directory (
cwd); useatto get a sibling handle bound elsewhere. - Worktree
Info - One attached worktree (git) / workspace (jj).
Enums§
- Backend
Kind - Which version-control tool backs a
Repo. - Change
Kind - How a file changed in the working copy.
- Create
Outcome - How a worktree was materialised. The facade always reports
Plain; theCowClonedvariant exists so a consumer that layers a copy-on-write strategy on top can reuse this type. - Error
- An error from a
Repooperation. - Operation
State - Whether the working copy is mid-operation, unified across the backends’
different models: git exposes an in-progress merge or rebase as on-disk state
(
MERGE_HEAD/ arebase-*dir), while jj has no multi-step operations — it records a conflict directly on the working-copy change.
Traits§
- VcsRepo
- The backend-agnostic common surface of
Repo, as a trait — so a consumer can hold aBox<dyn VcsRepo>/&dyn VcsRepoand code against the operations without naming theProcessRunnergeneric or wrappingRepothemselves.
Functions§
- detect
- Walk up from
startto the filesystem root looking for a repository. A.jjdirectory wins over.git(colocated repos are driven through jj);.gitmay be a directory or a gitlink file (a linked worktree/submodule). Pure filesystem probing — no subprocess.