File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed
Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 11use std:: process:: Command ;
22
33fn main ( ) {
4- // Emit the short git commit hash at build time.
5- let commit = Command :: new ( "git" )
4+ // Emit the short git commit hash at build time when available .
5+ if let Some ( commit) = Command :: new ( "git" )
66 . args ( [ "rev-parse" , "--short" , "HEAD" ] )
77 . output ( )
88 . ok ( )
99 . filter ( |o| o. status . success ( ) )
1010 . map ( |o| String :: from_utf8_lossy ( & o. stdout ) . trim ( ) . to_string ( ) )
11- . unwrap_or_else ( || "unknown" . into ( ) ) ;
12-
13- println ! ( "cargo:rustc-env=GIT_COMMIT={commit}" ) ;
11+ {
12+ println ! ( "cargo:rustc-env=GIT_COMMIT={commit}" ) ;
13+ }
1414
1515 // Re-run if HEAD changes (new commit).
1616 println ! ( "cargo:rerun-if-changed=../.git/HEAD" ) ;
Original file line number Diff line number Diff line change @@ -436,8 +436,11 @@ fn handle_peek<E: SendableError>(
436436fn landing_page_html ( ) -> String {
437437 const TEMPLATE : & str = include_str ! ( "../static/index.html" ) ;
438438 const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
439- const COMMIT : & str = env ! ( "GIT_COMMIT" ) ;
440- TEMPLATE . replace ( "{{VERSION}}" , VERSION ) . replace ( "{{COMMIT}}" , COMMIT )
439+ let version_string = match option_env ! ( "GIT_COMMIT" ) {
440+ Some ( commit) => format ! ( "payjoin-mailroom-v{VERSION} @ {commit}" ) ,
441+ None => format ! ( "payjoin-mailroom-v{VERSION}" ) ,
442+ } ;
443+ TEMPLATE . replace ( "{{VERSION_STRING}}" , & version_string)
441444}
442445
443446async fn handle_directory_home_path ( ) -> Result < Response < Body > , HandlerError > {
@@ -799,7 +802,6 @@ mod tests {
799802 #[ test]
800803 fn landing_page_contains_version ( ) {
801804 let html = landing_page_html ( ) ;
802- assert ! ( !html. contains( "{{VERSION}}" ) ) ;
803- assert ! ( !html. contains( "{{COMMIT}}" ) ) ;
805+ assert ! ( !html. contains( "{{VERSION_STRING}}" ) ) ;
804806 }
805807}
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ <h2>OHTTP Relay</h2>
242242 </ main >
243243
244244 < footer >
245- < span > < code > payjoin-mailroom-v{{VERSION}} @ {{COMMIT }}</ code > </ span >
245+ < span > < code > {{VERSION_STRING }}</ code > </ span >
246246 < span
247247 > Copyright ©
248248 < script >
You can’t perform that action at this time.
0 commit comments