mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
15 lines
431 B
Rust
15 lines
431 B
Rust
//! Just embed git-hash to `--version`
|
|
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
let rev = rev().unwrap_or_else(|| "???????".to_string());
|
|
println!("cargo:rustc-env=REV={}", rev)
|
|
}
|
|
|
|
fn rev() -> Option<String> {
|
|
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().ok()?;
|
|
let stdout = String::from_utf8(output.stdout).ok()?;
|
|
let short_hash = stdout.get(0..7)?;
|
|
Some(short_hash.to_owned())
|
|
}
|