File tree 3 files changed +13
-5
lines changed
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,6 @@ RUST_SOEXT.freebsd=so
134
134
RUST_SOEXT.macos =dylib
135
135
136
136
build :
137
- CARGO_FLAGS = cargo:rustc-env=GITHASH=$(git rev-parse HEAD ) ; $(CARGO_FLAGS )
138
137
ifeq ($(SAN ) ,)
139
138
export RUSTFLAGS=$(RUSTFLAGS) ;\
140
139
cargo build --all --all-targets $(CARGO_FLAGS)
Original file line number Diff line number Diff line change
1
+ use std:: process:: Command ;
2
+
3
+ fn main ( ) {
4
+ // Expose GIT_SHA env var
5
+ let gitsha = Command :: new ( "git" ) . args ( & [ "rev-parse" , "HEAD" ] ) . output ( ) ;
6
+ if let Ok ( sha) = gitsha {
7
+ let sha = String :: from_utf8 ( sha. stdout ) . unwrap ( ) ;
8
+ println ! ( "cargo:rustc-env=GIT_SHA={}" , sha) ;
9
+ }
10
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ pub mod manager;
27
27
mod nodevisitor;
28
28
pub mod redisjson;
29
29
30
+ pub const GIT_SHA : Option < & ' static str > = std:: option_env!( "GIT_SHA" ) ;
31
+
30
32
pub const REDIS_JSON_TYPE_VERSION : i32 = 3 ;
31
33
32
34
pub static REDIS_JSON_TYPE : RedisType = RedisType :: new (
@@ -400,10 +402,7 @@ macro_rules! redis_json_module_create {(
400
402
}
401
403
402
404
fn intialize( ctx: & Context , args: & Vec <RedisString >) -> Status {
403
- ctx. log_notice( format!( "git_sha={}" ,
404
- option_env!( "GITHASH" )
405
- . unwrap_or( "unknown" )
406
- ) ) ;
405
+ ctx. log_notice( & format!( "git sha: {}" , match GIT_SHA { Some ( sha) => sha, _ => "unknown" } ) ) ;
407
406
export_shared_api( ctx) ;
408
407
ctx. set_module_options( ModuleOptions :: HANDLE_IO_ERRORS ) ;
409
408
ctx. log_notice( "Enabled diskless replication" ) ;
You can’t perform that action at this time.
0 commit comments