Skip to main content

Crate vcs_core

Crate vcs_core 

Source
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/.jj repository (jj wins when colocated), returning the BackendKind and 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 with Repo::open; re-anchor it to another directory with Repo::at without threading a dir argument through every call.

Tool-specific operations stay on the underlying typed clients, reachable via the Repo::git / Repo::jj escape hatches.

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§

pub use vcs_git;
pub use vcs_jj;

Structs§

DiffStat
Aggregate insertion/deletion counts for the working copy.
FileChange
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); use at to get a sibling handle bound elsewhere.
WorktreeInfo
One attached worktree (git) / workspace (jj).

Enums§

BackendKind
Which version-control tool backs a Repo.
ChangeKind
How a file changed in the working copy.
CreateOutcome
How a worktree was materialised. The facade always reports Plain; the CowCloned variant exists so a consumer that layers a copy-on-write strategy on top can reuse this type.
Error
An error from a Repo operation.

Functions§

detect
Walk up from start to the filesystem root looking for a repository. A .jj directory wins over .git (colocated repos are driven through jj); .git may be a directory or a gitlink file (a linked worktree/submodule). Pure filesystem probing — no subprocess.

Type Aliases§

Result
Result specialised to the facade Error.