mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 20:04:30 +08:00
build.rs: Use Cargo_PKG_VERSION if no version could be found
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
`cargo build --git` clones a git repo without any tags, so you get a version like ``` fish, version f3fc743fc ``` which is *just* the commit hash and missing the "3.7.1-NUM-g" part. So, if we hit that case (detected because it has no ".", under the assumption that we'll never make a version that's just "4" instead of "4.0"), we prepend the version from Cargo.toml.
This commit is contained in:
parent
de13e6f9af
commit
0dfc490721
13
build.rs
13
build.rs
|
@ -268,9 +268,22 @@ fn get_version(src_dir: &Path) -> String {
|
|||
if let Ok(output) = Command::new("git").args(args).output() {
|
||||
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !rev.is_empty() {
|
||||
// If it contains a ".", we have a proper version like "3.7",
|
||||
// or "23.2.1-1234-gfab1234"
|
||||
if rev.contains(".") {
|
||||
return rev;
|
||||
}
|
||||
// If it doesn't, we probably got *just* the commit SHA,
|
||||
// like "f1242abcdef".
|
||||
// So we prepend the crate version so it at least looks like
|
||||
// "3.8-gf1242abcdef"
|
||||
// This lacks the commit *distance*, but that can't be helped without
|
||||
// tags.
|
||||
let version = env!("CARGO_PKG_VERSION").to_owned();
|
||||
return version + "-g" + &rev;
|
||||
}
|
||||
}
|
||||
// TODO: Do we just use the cargo version here?
|
||||
|
||||
"unknown".to_string()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user