-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't break build when git is missing (#856)
If git is missing, the build script will fail. This changes it so that it uses the string `unknown` instead of the version. This version is currently only used to log a warning if there is a version mismatch between the client and server. We should switch to using only the version number for this soon anyway now that the protocol is more stable.
- Loading branch information
Showing
5 changed files
with
12 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let output = Command::new("git") | ||
let git_hash = Command::new("git") | ||
.args(["rev-parse", "HEAD"]) | ||
.output() | ||
.expect("Failed to execute git command"); | ||
|
||
let git_hash = String::from_utf8_lossy(&output.stdout).trim().to_string(); | ||
let git_hash: String = git_hash.chars().take(8).collect(); | ||
.map(|output| { | ||
let hash = String::from_utf8_lossy(&output.stdout).trim().to_string(); | ||
hash.chars().take(8).collect::<String>() | ||
}) | ||
.unwrap_or_else(|_| String::from("unknown")); | ||
|
||
println!("cargo:rustc-env=GIT_HASH={}", git_hash); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters