]> git.lizzy.rs Git - rust.git/blob - crates/rust-analyzer/build.rs
Rename folder
[rust.git] / crates / rust-analyzer / build.rs
1 //! Just embed git-hash to `--version`
2
3 use std::process::Command;
4
5 fn main() {
6     let rev = rev().unwrap_or_else(|| "???????".to_string());
7     println!("cargo:rustc-env=REV={}", rev)
8 }
9
10 fn rev() -> Option<String> {
11     let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().ok()?;
12     let stdout = String::from_utf8(output.stdout).ok()?;
13     let short_hash = stdout.get(0..7)?;
14     Some(short_hash.to_owned())
15 }