Skip to content

Commit

Permalink
Merge pull request #31 from afh/no_git_get_version
Browse files Browse the repository at this point in the history
Use CARGO_PKG_VERSION when git is not installed
  • Loading branch information
humblepenguinn authored Feb 12, 2024
2 parents 4ccc92e + d2b8dab commit c66b6b9
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,22 @@ fn generate_completions(
@return String
*/
fn get_version() -> String {
let mut version_env: String = "".to_string();
let mut cmd = process::Command::new("git");

cmd.arg("describe");
cmd.arg("--abbrev=0");
cmd.arg("--tags=0");

match cmd.status() {
Ok(status) => {
if status.success() {
if let Ok(output) = cmd.output() {
return format!("{:?}", output);
}
} else {
println!("Error: Cannot get build version using `git` using CARGO_PKG_VERSION");
version_env = env!("CARGO_PKG_VERSION").to_string();
if let Ok(status) = cmd.status() {
if status.success() {
if let Ok(output) = cmd.output() {
return format!("{:?}", output);
}
}
Err(e) => {
panic!("Error: Failed getting build version with git: {}", e);
}
}

version_env
println!("Error: Cannot get build version using `git` using CARGO_PKG_VERSION");
return env!("CARGO_PKG_VERSION").to_string();
}

/*
Expand Down

0 comments on commit c66b6b9

Please sign in to comment.