forked from mirrors/jj
build: strip newline from "git rev-parse" output
It works because a build command is line oriented, but it's technically wrong to include "\n" in git_hash.
This commit is contained in:
parent
7a8903e5e7
commit
9e027c0aa2
1 changed files with 3 additions and 1 deletions
4
build.rs
4
build.rs
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
use std::process::Command;
|
||||
use std::str;
|
||||
|
||||
use cargo_metadata::MetadataCommand;
|
||||
|
||||
|
@ -56,7 +57,8 @@ fn get_git_hash() -> Option<String> {
|
|||
if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
||||
if output.status.success() {
|
||||
println!("cargo:rerun-if-changed=.git/HEAD");
|
||||
return Some(String::from_utf8(output.stdout).unwrap());
|
||||
let line = str::from_utf8(&output.stdout).unwrap();
|
||||
return Some(line.trim_end().to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue