Skip to main content

Crate vcs_git

Crate vcs_git 

Source
Expand description

vcs-git — automate Git from Rust through CLI process execution.

Async, mockable, and structured-error: consumers depend on the GitApi trait and substitute a mock for the real Git client in tests. Commands run inside an OS job (via processkit) so a git subprocess is never orphaned, and honour an optional timeout.

use vcs_git::{Git, GitApi};
use std::path::Path;

let branch = git.current_branch(Path::new(".")).await?;

Two test seams: enable the mock feature for a mockall-generated MockGitApi, or inject a fake runner with Git::with_runner(ScriptedRunner).

Structs§

Branch
A local branch from git branch.
Commit
A commit, parsed from a \x1f-delimited git log line.
DiffStat
Aggregate line/file counts from git diff --shortstat.
FileDiff
One file’s entry in a parsed git-format unified diff (git diff or jj diff --git).
Git
The real Git client. Generic over the ProcessRunner so tests can inject a fake process executor; Git::new() uses the real job-backed runner.
Hunk
A single @@ … @@ hunk within a FileDiff.
ProcessResult
The captured result of running a process to completion.
StatusEntry
One entry from git status --porcelain=v1 -z (XY <path>, NUL-delimited).
Worktree
A worktree from git worktree list --porcelain.
WorktreeAdd
Options for GitApi::worktree_add (git worktree add).

Enums§

ChangeKind
How a file changed in a unified diff.
DiffLine
One line inside a Hunk, tagged by its role. The stored text excludes the leading /+/- marker.
DiffSpec
What a GitApi::diff / GitApi::diff_text call compares.
Error
Errors produced when launching or running a child process.

Constants§

BINARY
Name of the underlying CLI binary this crate drives.

Traits§

GitApi
The Git operations this crate exposes — the interface consumers code against and mock in tests.

Functions§

is_merge_conflict
Whether a failed merge/merge_commit stopped on a merge conflict.
is_nothing_to_commit
Whether a failed commit/commit_paths reported nothing to commit (a clean tree), as opposed to a real error.
is_transient_fetch_error
Whether a failed fetch/fetch_remote_branch/remote_branch_exists looks transient (DNS, timeout, dropped connection) and is worth retrying.

Type Aliases§

Result
Crate result alias.