Print a deterministic length of commit hash in --version
This commit is contained in:
parent
a1361bd0d5
commit
17c5869dff
12
build.rs
12
build.rs
@ -25,7 +25,7 @@ fn main() {
|
||||
// (git not installed or if this is not a git repository) just return an empty string.
|
||||
fn commit_info() -> String {
|
||||
match (channel(), commit_hash(), commit_date()) {
|
||||
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash.trim_end(), date),
|
||||
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash, date),
|
||||
_ => String::new(),
|
||||
}
|
||||
}
|
||||
@ -39,11 +39,13 @@ fn channel() -> String {
|
||||
}
|
||||
|
||||
fn commit_hash() -> Option<String> {
|
||||
Command::new("git")
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|r| String::from_utf8(r.stdout).ok())
|
||||
.ok()?;
|
||||
let mut stdout = String::from_utf8(output.stdout).ok()?;
|
||||
stdout.truncate(10);
|
||||
Some(stdout)
|
||||
}
|
||||
|
||||
fn commit_date() -> Option<String> {
|
||||
|
Loading…
Reference in New Issue
Block a user