-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.rs
45 lines (40 loc) · 1.06 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
extern crate foreman;
use std::process::Command;
use std::process::Output;
fn main() {
set_git_ver_env_var();
}
fn set_git_ver_env_var() {
let git_ver = Command::new("git")
.args(&[
"describe",
"--tags",
"--first-parent",
"--always",
"--dirty",
"--broken",
])
.output();
let git_ver = match git_ver {
Ok(Output {
ref status,
ref stdout,
..
}) if status.success() => {
let v = String::from_utf8_lossy(stdout);
eprintln!("Detected version from Git repository: {}", v);
v
}
o => {
foreman::warning(&format!(
"Error running `git describe`: {}",
match o {
Ok(Output { ref stderr, .. }) => String::from_utf8_lossy(stderr).to_string(),
Err(e) => e.to_string(),
}
));
"".into()
}
};
foreman::env_var("IRC_BOT_RS_GIT_VERSION", &git_ver);
}