pub trait GitRepo {
// Required methods
fn head_commit(&self) -> Result<String>;
fn is_work_tree(&self) -> bool;
fn shortlog(&self, since: Option<&str>) -> Result<String>;
fn tags(&self) -> Result<Vec<String>>;
fn git_common_dir(&self) -> Result<PathBuf>;
}Expand description
Read-only view of the git repository under audit/release. The detector and
release engine read repo facts through this port rather than shelling out
to git themselves.
The detector’s queries are deliberately best-effort: an unborn or
non-repository root makes several of these fail, and the detector treats
every such failure as “absent” (no committers, no tags) rather than an
error — mirroring the read-only, never-mutating infer-repo-facts.py.
Required Methods§
Sourcefn head_commit(&self) -> Result<String>
fn head_commit(&self) -> Result<String>
The full commit hash of HEAD. Err on an unborn repository (no
commits yet) or a non-repository root — the detector reads this as
“the repo has no commits”.
Sourcefn is_work_tree(&self) -> bool
fn is_work_tree(&self) -> bool
Whether the root is inside a git work tree (git rev-parse --is-inside-work-tree succeeds). false for a non-repository root or
on any git error.
Sourcefn shortlog(&self, since: Option<&str>) -> Result<String>
fn shortlog(&self, since: Option<&str>) -> Result<String>
Raw git shortlog -sne --all HEAD output — one line per distinct
committer. When since is set (a git date expression such as
"1 year ago"), the log is limited to commits at or after it. Err on
any git failure (an unborn/empty repo); the detector counts that as zero
committers.
The repository’s tag names (git tag --list), trimmed and with empty
lines dropped. Err on any git failure; the detector reads that as “no
tags”.
Sourcefn git_common_dir(&self) -> Result<PathBuf>
fn git_common_dir(&self) -> Result<PathBuf>
The common git directory (git rev-parse --git-common-dir), resolved
to an absolute path. The release journal roots its state under here so all
linked worktrees of one repo share a single release-state root, and
submodules / bare repos / GIT_DIR overrides resolve correctly — a
literal .git/ concatenation is not a portable substitute (ADR-0003
§3, the panel’s repeated correctness landmine). Err on any git failure.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".