Return the timestamp of the latest git commit in seconds since the Unix epoch.
(dir: &Utf8Path)
| 419 | |
| 420 | /// Return the timestamp of the latest git commit in seconds since the Unix epoch. |
| 421 | fn 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. |
no test coverage detected