mirror of
https://github.com/Noratrieb/uptime.git
synced 2026-01-14 16:45:06 +01:00
write website
This commit is contained in:
parent
24abf6d98c
commit
7ff9a67148
15 changed files with 1580 additions and 38 deletions
35
build.rs
Normal file
35
build.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
fn main() {
|
||||
// Always rerun.
|
||||
|
||||
let version = if let Ok(commit) = try_get_commit() {
|
||||
match has_no_changes() {
|
||||
Ok(true) => commit,
|
||||
Ok(false) => format!("{commit} (*)"),
|
||||
Err(_) => format!("{commit} (?)"),
|
||||
}
|
||||
} else {
|
||||
"unknown".into()
|
||||
};
|
||||
|
||||
println!("cargo:rustc-env=GIT_COMMIT={version}");
|
||||
}
|
||||
|
||||
fn try_get_commit() -> eyre::Result<String> {
|
||||
let stdout = std::process::Command::new("git")
|
||||
.arg("rev-parse")
|
||||
.arg("HEAD")
|
||||
.output()?
|
||||
.stdout;
|
||||
|
||||
let stdout = String::from_utf8(stdout)?;
|
||||
|
||||
Ok(stdout.trim().to_owned())
|
||||
}
|
||||
|
||||
fn has_no_changes() -> eyre::Result<bool> {
|
||||
Ok(std::process::Command::new("git")
|
||||
.args(["diff", "--no-ext-diff", "--quiet", "--exit-code"])
|
||||
.output()?
|
||||
.status
|
||||
.success())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue