(sh: &Shell)
| 382 | |
| 383 | #[context("Finding gitrev")] |
| 384 | fn 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. |
no test coverage detected