diff options
author | extrawurst <mail@rusticorn.com> | 2024-03-27 13:07:05 +0000 |
---|---|---|
committer | extrawurst <776816+extrawurst@users.noreply.github.com> | 2024-03-27 14:24:05 +0000 |
commit | 2ec6d632ed16f201c6f9055abed8e5fb316326ec (patch) | |
tree | 7877aa81278eaa879293cc351956654adc4865db /src | |
parent | 096695305055fb6b49c1f4593833ad0862fab3bb (diff) |
encode nightly version, commit, date into binary
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/popups/help.rs | 6 | ||||
-rw-r--r-- | src/version.rs | 35 |
4 files changed, 6 insertions, 40 deletions
diff --git a/src/args.rs b/src/args.rs index 2effe5fc..74654220 100644 --- a/src/args.rs +++ b/src/args.rs @@ -2,7 +2,7 @@ use crate::bug_report; use anyhow::{anyhow, Result}; use asyncgit::sync::RepoPath; use clap::{ - crate_authors, crate_description, crate_name, crate_version, Arg, + crate_authors, crate_description, crate_name, Arg, Command as ClapApp, }; use simplelog::{Config, LevelFilter, WriteLogger}; @@ -63,7 +63,7 @@ pub fn process_cmdline() -> Result<CliArgs> { fn app() -> ClapApp { ClapApp::new(crate_name!()) .author(crate_authors!()) - .version(crate_version!()) + .version(env!("GITUI_BUILD_NAME")) .about(crate_description!()) .help_template( "\ diff --git a/src/main.rs b/src/main.rs index 84a7a82e..26093811 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,6 @@ mod string_utils; mod strings; mod tabs; mod ui; -mod version; mod watcher; use crate::{app::App, args::process_cmdline}; diff --git a/src/popups/help.rs b/src/popups/help.rs index 9933d5c7..d472257a 100644 --- a/src/popups/help.rs +++ b/src/popups/help.rs @@ -6,7 +6,6 @@ use crate::{ app::Environment, keys::{key_match, SharedKeyConfig}, strings, ui, - version::Version, }; use anyhow::Result; use asyncgit::hash; @@ -70,7 +69,10 @@ impl DrawableComponent for HelpPopup { f.render_widget( Paragraph::new(Line::from(vec![Span::styled( - Cow::from(format!("gitui {}", Version::new(),)), + Cow::from(format!( + "gitui {}", + env!("GITUI_BUILD_NAME"), + )), Style::default(), )])) .alignment(Alignment::Right), diff --git a/src/version.rs b/src/version.rs deleted file mode 100644 index 02af65c2..00000000 --- a/src/version.rs +++ /dev/null @@ -1,35 +0,0 @@ -use std::{env, fmt}; - -/// version type -#[derive(Default)] -pub struct Version { - major: u32, - minor: u32, - patch: u32, -} - -impl Version { - /// read version at compile time from env variables - pub fn new() -> Self { - let mut res = Self::default(); - let major_str = env!("CARGO_PKG_VERSION_MAJOR"); - if let Ok(major) = major_str.parse::<u32>() { - res.major = major; - } - let minor_str = env!("CARGO_PKG_VERSION_MINOR"); - if let Ok(minor) = minor_str.parse::<u32>() { - res.minor = minor; - } - let patch_str = env!("CARGO_PKG_VERSION_PATCH"); - if let Ok(patch) = patch_str.parse::<u32>() { - res.patch = patch; - } - res - } -} - -impl fmt::Display for Version { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "v{}.{}.{}", self.major, self.minor, self.patch) - } -} |