From 90f944709bc3b310b9bd2470e38296ba7e248b43 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Wed, 2 Dec 2020 21:18:55 -0800 Subject: [PATCH] fix git commit logic to work on gcloud (#1442) --- zebrad/src/application.rs | 9 +++++++-- zebrad/src/commands.rs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/zebrad/src/application.rs b/zebrad/src/application.rs index e1aa79bce..a93f78047 100644 --- a/zebrad/src/application.rs +++ b/zebrad/src/application.rs @@ -45,7 +45,12 @@ pub struct ZebradApp { } impl ZebradApp { - pub const GIT_COMMIT: &'static str = env!("VERGEN_SHA_SHORT"); + pub fn git_commit() -> &'static str { + const GIT_COMMIT_VERGEN: &str = env!("VERGEN_SHA_SHORT"); + const GIT_COMMIT_GCLOUD: Option<&str> = option_env!("SHORT_SHA"); + + GIT_COMMIT_GCLOUD.unwrap_or(GIT_COMMIT_VERGEN) + } } /// Initialize a new application instance. @@ -118,7 +123,7 @@ impl Application for ZebradApp { color_eyre::config::HookBuilder::default() .issue_url(concat!(env!("CARGO_PKG_REPOSITORY"), "/issues/new")) .add_issue_metadata("version", env!("CARGO_PKG_VERSION")) - .add_issue_metadata("git commit", Self::GIT_COMMIT) + .add_issue_metadata("git commit", Self::git_commit()) .issue_filter(|kind| match kind { color_eyre::ErrorKind::NonRecoverable(_) => true, color_eyre::ErrorKind::Recoverable(error) => { diff --git a/zebrad/src/commands.rs b/zebrad/src/commands.rs index bae373057..5968ca56a 100644 --- a/zebrad/src/commands.rs +++ b/zebrad/src/commands.rs @@ -53,7 +53,7 @@ impl ZebradCmd { impl Runnable for ZebradCmd { fn run(&self) { - let span = error_span!("", zebrad = ZebradApp::GIT_COMMIT); + let span = error_span!("", zebrad = ZebradApp::git_commit()); let _guard = span.enter(); match self { Generate(cmd) => cmd.run(),