MCPcopy Create free account
hub / github.com/base/base / git_revision

Method git_revision

acceptance/src/cli.rs:399–412  ·  view source on GitHub ↗

Reads the current Git revision and dirty state.

(root: &Path)

Source from the content-addressed store, hash-verified

397
398 /// Reads the current Git revision and dirty state.
399 pub fn git_revision(root: &Path) -> Result<String> {
400 let output = Command::new("git").args(["rev-parse", "HEAD"]).current_dir(root).output()?;
401 if !output.status.success() {
402 bail!("git rev-parse failed");
403 }
404
405 let mut sha = String::from_utf8(output.stdout)?.trim().to_owned();
406 let dirty =
407 Command::new("git").args(["status", "--porcelain"]).current_dir(root).output()?;
408 if !dirty.stdout.is_empty() {
409 sha.push_str("-dirty");
410 }
411 Ok(sha)
412 }
413
414 /// Quotes one path for inert reproduction text.
415 pub fn shell_quote(path: &Path) -> String {

Callers

nothing calls this directly

Calls 4

outputMethod · 0.80
newFunction · 0.50
successMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected