Skip to content
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
20 changes: 20 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::process::Command;

fn main() {
// Expose GIT_SHA env var
let git_sha = Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.output();
if let Ok(sha) = git_sha {
let sha = String::from_utf8(sha.stdout).unwrap();
println!("cargo:rustc-env=GIT_SHA={}", sha);
}
// Expose GIT_BRANCH env var
let git_branch = Command::new("git")
.args(&["rev-parse", "--abbrev-ref", "HEAD"])
.output();
if let Ok(branch) = git_branch {
let branch = String::from_utf8(branch.stdout).unwrap();
println!("cargo:rustc-env=GIT_BRANCH={}", branch);
}
}
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub mod manager;
mod nodevisitor;
pub mod redisjson;

pub const GIT_SHA: Option<&'static str> = std::option_env!("GIT_SHA");
pub const GIT_BRANCH: Option<&'static str> = std::option_env!("GIT_BRANCH");

pub const REDIS_JSON_TYPE_VERSION: i32 = 3;

pub static REDIS_JSON_TYPE: RedisType = RedisType::new(
Expand Down Expand Up @@ -400,6 +403,11 @@ macro_rules! redis_json_module_create {(
}

fn intialize(ctx: &Context, args: &Vec<RedisString>) -> Status {
ctx.log_notice(&format!("version: {} git sha: {} branch: {}",
$version,
match GIT_SHA { Some(val) => val, _ => "unknown"},
match GIT_BRANCH { Some(val) => val, _ => "unknown"},
));
export_shared_api(ctx);
ctx.set_module_options(ModuleOptions::HANDLE_IO_ERRORS);
ctx.log_notice("Enabled diskless replication");
Expand Down