forked from Mirrors/helix
fix: Only parse git revision, don't use the tag for version
If building from source and the source is contained in a larger repository, we'd contain the wrong version. It's also easy to accidentally have a newer tag that would change the version.imgbot
parent
d6b6ad879e
commit
d3221b03a2
@ -1,12 +1,17 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let git_hash = Command::new("git")
|
let git_hash = Command::new("git")
|
||||||
.args(&["describe", "--dirty"])
|
.args(&["rev-parse", "HEAD"])
|
||||||
.output()
|
.output()
|
||||||
.map(|x| String::from_utf8(x.stdout).ok())
|
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.and_then(|x| String::from_utf8(x.stdout).ok());
|
||||||
.unwrap_or_else(|| String::from(env!("CARGO_PKG_VERSION")));
|
|
||||||
println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", git_hash);
|
let version: Cow<_> = match git_hash {
|
||||||
|
Some(git_hash) => format!("{} ({})", env!("CARGO_PKG_VERSION"), &git_hash[..8]).into(),
|
||||||
|
None => env!("CARGO_PKG_VERSION").into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue