Expand description
Pure-Rust git helpers (via gix). The single home for read-side
git inspection so the rest of the crate never shells out to the
git binary. No std::process::Command, no libgit2/C — matches
nornir’s pure-Rust ethos (gix over libgit2, like ureq over curl).
Write/network release operations (commit-on-release, push) live in
nornir’s release::publish. The write helpers here — init and
commit_all — exist only to build new repositories from scratch
(test fixtures and the synthetic-repo generator) without ever
shelling out; they use a fixed, deterministic identity so fixtures
are reproducible and need no ambient git config.
Structs§
- Local
Push Report - Outcome of a
push_to_local_remote. - Worktree
Freshness - A working-tree freshness reading: whether the tree is dirty and a stable content digest of the porcelain status (AUT6 / freshness gate).
Constants§
- CLEAN_
WORKTREE_ DIGEST - Sentinel digest for a clean working tree (no tracked modifications, nothing staged, no untracked files). A fixed string so clients can test it without recomputing a hash of the empty set.
Functions§
- clone_
or_ fetch - Ensure
destis an up-to-date clone ofurl: clone if absent, else fetch. Returns the resultingHEADSHA. SSH remotes use the deploy key atssh_key(resolved vianornir_ssh_key_pathwhenNone). - commit_
all - Snapshot the entire working tree (every file except those under
.git/) into a new commit onHEAD, returning the commit SHA. - head_
branch - Short branch name for
HEAD, or"(detached)"when detached. gix-first,git symbolic-reffallback (seehead_sha). - head_
sha - Full 40-char hex SHA of the commit
HEADpoints at. - head_
sha_ and_ branch (sha, branch)forHEAD. gix-first,git-fallback for each half (seehead_sha).- https_
to_ ssh - Rewrite an
https://host/owner/repo(.git)(orhttp://) URL to its scp-like SSH formgit@host:owner/repo.git. ReturnsNonewhenurlisn’t a plain http(s) URL with both a host and a path we can rewrite. Used to prefer SSH (deploy-key, no credential prompt) over https for private remotes. - init
- Initialise a fresh git repository at
root(pure-Rust viagix). The directory is created if missing. Used by test fixtures and the synthetic-repo generator so setup code is also free ofgitsubprocesses. - is_
ssh_ url truefor SSH-style remotes (git@host:…orssh://…).- nornir_
ssh_ key_ path - Resolve the deploy-key path the server uses for git-over-SSH. Mirrors the
CLI’s
nornir keyresolution: honorsNORNIR_SSH_DIR, else thenornirsystem user’s home (/home/nornir/.ssh), else a per-user dev location that never touches the operator’s own~/.ssh. Returns the private key path only if it exists. - push_
to_ local_ remote - Fast-forward PUSH to a LOCAL/file git remote, pure-Rust (no send-pack).
- set_
head_ and_ checkout - Point an existing clone at
branch(→ commitsha) and materialize its worktree from that commit. Pure-gix (no shell-out): updatesrefs/heads/ <branch>+HEAD, then writes the tree onto disk.branchis the SHORT name (e.g.main);shaits peeled commit. Used by the fat auto-materialize path to honor a member’s pinnedbranchafter a default-HEAD clone. - tag_
commit_ sha - Commit SHA the tag
refs/tags/<tag>resolves to, peeling annotated tags down to their target commit.Ok(None)if the tag is absent. - tag_
lightweight - Create a lightweight tag
refs/tags/<name>pointing attarget_sha. Pure-gix (no shell). Fails if the tag already exists. - tag_
points_ at_ head - True iff
refs/tags/<tag>exists and (after peeling) points at the same commit asHEAD. - worktree_
freshness - Compute the working-tree freshness of the repo at
root, in-process via gix (no shelling out to thegitbinary).