File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed 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 git_sha = Command :: new ( "git" )
6
+ . args ( & [ "rev-parse" , "--short" , "HEAD" ] )
7
+ . output ( ) ;
8
+ if let Ok ( sha) = git_sha {
9
+ let sha = String :: from_utf8 ( sha. stdout ) . unwrap ( ) ;
10
+ println ! ( "cargo:rustc-env=GIT_SHA={}" , sha) ;
11
+ }
12
+ // Expose GIT_BRANCH env var
13
+ let git_branch = Command :: new ( "git" )
14
+ . args ( & [ "rev-parse" , "--abbrev-ref" , "HEAD" ] )
15
+ . output ( ) ;
16
+ if let Ok ( branch) = git_branch {
17
+ let branch = String :: from_utf8 ( branch. stdout ) . unwrap ( ) ;
18
+ println ! ( "cargo:rustc-env=GIT_BRANCH={}" , branch) ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ 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
+ pub const GIT_BRANCH : Option < & ' static str > = std:: option_env!( "GIT_BRANCH" ) ;
32
+
30
33
pub const REDIS_JSON_TYPE_VERSION : i32 = 3 ;
31
34
32
35
pub static REDIS_JSON_TYPE : RedisType = RedisType :: new (
@@ -400,6 +403,11 @@ macro_rules! redis_json_module_create {(
400
403
}
401
404
402
405
fn intialize( ctx: & Context , args: & Vec <RedisString >) -> Status {
406
+ ctx. log_notice( & format!( "version: {} git sha: {} branch: {}" ,
407
+ $version,
408
+ match GIT_SHA { Some ( val) => val, _ => "unknown" } ,
409
+ match GIT_BRANCH { Some ( val) => val, _ => "unknown" } ,
410
+ ) ) ;
403
411
export_shared_api( ctx) ;
404
412
ctx. set_module_options( ModuleOptions :: HANDLE_IO_ERRORS ) ;
405
413
ctx. log_notice( "Enabled diskless replication" ) ;
You can’t perform that action at this time.
0 commit comments