Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print source code revision on startup #49

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::process::Command;
fn main() {
// runs git describe --always --dirty
if let Ok(output) = Command::new("git")
.args(["describe", "--always", "--dirty"])
.output()
{
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={git_hash}");
} else {
println!("cargo:rustc-env=GIT_HASH=UNKNOWN");
}
}
2 changes: 1 addition & 1 deletion hms2mqtt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pub mod simple_mqtt;

// internal interfaces
mod home_assistant_config;
mod protos;
mod protos;
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static REQUEST_DELAY: u64 = 30_500;

fn main() {
logging::init_logger();

info!("Running revision: {}", env!("GIT_HASH"));
if std::env::args().len() > 1 {
error!("Arguments passed. Tool is configured by config.toml in its path");
}
Expand Down