mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
Fix git describe abbrev length for reproducibility
Signed-off-by: Sylvain Bellemare <sbellem@gmail.com>
This commit is contained in:
parent
a8eca714da
commit
171e32e834
1 changed files with 7 additions and 2 deletions
|
|
@ -8,20 +8,25 @@ use std::process::Command;
|
||||||
|
|
||||||
use chrono::{Local, TimeZone, Utc};
|
use chrono::{Local, TimeZone, Utc};
|
||||||
|
|
||||||
|
/// Fixed abbreviation length for `git describe` output.
|
||||||
|
/// Ensures consistent version strings regardless of clone depth.
|
||||||
|
const GIT_ABBREV_LEN: u8 = 9;
|
||||||
|
|
||||||
pub(crate) fn generate_version(add_timestamp: bool, forced_version: Option<String>) {
|
pub(crate) fn generate_version(add_timestamp: bool, forced_version: Option<String>) {
|
||||||
let gitver = {
|
let gitver = {
|
||||||
if let Some(ver) = forced_version {
|
if let Some(ver) = forced_version {
|
||||||
ver.as_bytes().to_vec()
|
ver.as_bytes().to_vec()
|
||||||
} else {
|
} else {
|
||||||
|
let cmd = format!("git describe --long --abbrev={}", GIT_ABBREV_LEN);
|
||||||
let output = if cfg!(target_os = "windows") {
|
let output = if cfg!(target_os = "windows") {
|
||||||
Command::new("cmd")
|
Command::new("cmd")
|
||||||
.args(["/C", "git describe --long"])
|
.args(["/C", &cmd])
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process")
|
.expect("failed to execute process")
|
||||||
} else {
|
} else {
|
||||||
Command::new("sh")
|
Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg("git describe --long")
|
.arg(&cmd)
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process")
|
.expect("failed to execute process")
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue