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-delimitedgit logline. - Diff
Stat - Aggregate line/file counts from
git diff --shortstat. - File
Diff - One file’s entry in a parsed git-format unified diff (
git difforjj diff --git). - Git
- The real Git client. Generic over the
ProcessRunnerso tests can inject a fake process executor;Git::new()uses the real job-backed runner. - Hunk
- A single
@@ … @@hunk within aFileDiff. - Process
Result - The captured result of running a process to completion.
- Status
Entry - One entry from
git status --porcelain=v1 -z(XY <path>, NUL-delimited). - Worktree
- A worktree from
git worktree list --porcelain. - Worktree
Add - Options for
GitApi::worktree_add(git worktree add).
Enums§
- Change
Kind - How a file changed in a unified diff.
- Diff
Line - One line inside a
Hunk, tagged by its role. The stored text excludes the leading/+/-marker. - Diff
Spec - What a
GitApi::diff/GitApi::diff_textcall 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_commitstopped on a merge conflict. - is_
nothing_ to_ commit - Whether a failed
commit/commit_pathsreported 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_existslooks transient (DNS, timeout, dropped connection) and is worth retrying.
Type Aliases§
- Result
- Crate result alias.