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

Function git_source_date_epoch

crates/xtask/src/xtask.rs:421–432  ·  view source on GitHub ↗

Return the timestamp of the latest git commit in seconds since the Unix epoch.

(dir: &Utf8Path)

Source from the content-addressed store, hash-verified

419
420/// Return the timestamp of the latest git commit in seconds since the Unix epoch.
421fn git_source_date_epoch(dir: &Utf8Path) -> Result<u64> {
422 let o = Command::new("git")
423 .args(["log", "-1", "--pretty=%ct"])
424 .current_dir(dir)
425 .output()?;
426 if !o.status.success() {
427 anyhow::bail!("git exited with an error: {:?}", o);
428 }
429 let buf = String::from_utf8(o.stdout).context("Failed to parse git log output")?;
430 let r = buf.trim().parse()?;
431 Ok(r)
432}
433
434/// When using cargo-vendor-filterer --format=tar, the config generated has a bogus source
435/// directory. This edits it to refer to vendor/ as a stable relative reference.

Callers 1

impl_packageFunction · 0.85

Calls 2

argsMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected