fix git commit logic to work on gcloud (#1442)

This commit is contained in:
Jane Lusby 2020-12-02 21:18:55 -08:00 committed by GitHub
parent c0bbac89b3
commit 90f944709b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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) => {

View File

@ -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(),