diff options
author | 绅士喵 <meow.i5.br@gmail.com> | 2019-06-07 02:46:32 +0800 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-06-06 18:46:32 +0000 |
commit | f2b1bfdf37aea62e79b1791127eaf1507edfecd9 (patch) | |
tree | 89113fa0ae6bbe421fcae1f1cfc006228c7e1b0e | |
parent | f15ef63edbbc5e4e685b018311e2f6424db0b0c9 (diff) | |
download | alacritty-f2b1bfdf37aea62e79b1791127eaf1507edfecd9.tar.gz alacritty-f2b1bfdf37aea62e79b1791127eaf1507edfecd9.zip |
Fix build without git
-rw-r--r-- | alacritty/build.rs | 2 | ||||
-rw-r--r-- | alacritty/src/cli.rs | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/alacritty/build.rs b/alacritty/build.rs index 1ad0def4..b39921c0 100644 --- a/alacritty/build.rs +++ b/alacritty/build.rs @@ -13,6 +13,6 @@ // limitations under the License. fn main() { - let hash = rustc_tools_util::get_commit_hash().expect("couldn't get commit hash"); + let hash = rustc_tools_util::get_commit_hash().unwrap_or_default(); println!("cargo:rustc-env=GIT_HASH={}", hash); } diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs index 3ecea644..9e7493bc 100644 --- a/alacritty/src/cli.rs +++ b/alacritty/src/cli.rs @@ -61,12 +61,16 @@ impl Default for Options { impl Options { /// Build `Options` from command line arguments. pub fn new() -> Self { - let mut options = Options::default(); + let mut version = crate_version!().to_owned(); + let commit_hash = env!("GIT_HASH"); + if !commit_hash.is_empty() { + version = format!("{} ({})", version, commit_hash); + } - let version_string = format!("{} ({})", crate_version!(), env!("GIT_HASH")); + let mut options = Options::default(); let matches = App::new(crate_name!()) - .version(version_string.as_str()) + .version(version.as_str()) .author(crate_authors!("\n")) .about(crate_description!()) .arg(Arg::with_name("ref-test").long("ref-test").help("Generates ref test")) |