MCPcopy Create free account
hub / github.com/bootc-dev/bootc / gitrev

Function gitrev

crates/xtask/src/xtask.rs:384–401  ·  view source on GitHub ↗
(sh: &Shell)

Source from the content-addressed store, hash-verified

382
383#[context("Finding gitrev")]
384fn gitrev(sh: &Shell) -> Result<String> {
385 if let Ok(rev) = cmd!(sh, "git describe --tags --exact-match")
386 .ignore_stderr()
387 .read()
388 {
389 Ok(gitrev_to_version(&rev))
390 } else {
391 // Grab the abbreviated commit
392 let abbrev_commit = cmd!(sh, "git rev-parse HEAD")
393 .read()?
394 .chars()
395 .take(10)
396 .collect::<String>();
397 let timestamp = git_timestamp(sh)?;
398 // We always inject the timestamp first to ensure that newer is better.
399 Ok(format!("{timestamp}.g{abbrev_commit}"))
400 }
401}
402
403/// Return a string formatted version of the git commit timestamp, up to the minute
404/// but not second because, well, we're not going to build more than once a second.

Callers 1

impl_packageFunction · 0.85

Calls 3

gitrev_to_versionFunction · 0.85
git_timestampFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected