diff options
author | extrawurst <mail@rusticorn.com> | 2024-03-27 13:02:31 +0000 |
---|---|---|
committer | extrawurst <mail@rusticorn.com> | 2024-03-27 13:02:31 +0000 |
commit | 4cc6b459cc3b6b98ce7131f017bf2b2c85a6a397 (patch) | |
tree | 7c1a84c26ea209bfd4fd5fd2e7dfa31aa8f4347e | |
parent | 89e9f855cb55aa83559585ed0ce999276fe6817d (diff) |
Revert "encode nightly version, commit, date into binary"
This reverts commit 89e9f855cb55aa83559585ed0ce999276fe6817d.
-rw-r--r-- | Cargo.lock | 30 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | build.rs | 38 | ||||
-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 |
8 files changed, 46 insertions, 84 deletions
@@ -305,20 +305,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] -name = "compile-time" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55ede5279d4d7c528906853743abeb26353ae1e6c440fcd6d18316c2c2dd903" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "rustc_version", - "semver", - "time", -] - -[[package]] name = "core-foundation-sys" version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -747,7 +733,6 @@ dependencies = [ "bytesize", "chrono", "clap", - "compile-time", "crossbeam-channel", "crossterm", "dirs", @@ -1395,15 +1380,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] name = "rustix" version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1451,12 +1427,6 @@ dependencies = [ ] [[package]] -name = "semver" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" - -[[package]] name = "serde" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -12,7 +12,6 @@ readme = "README.md" license = "MIT" categories = ["command-line-utilities"] keywords = ["git", "gui", "cli", "terminal", "ui"] -build = "build.rs" [dependencies] anyhow = "1.0" @@ -65,9 +64,6 @@ which = "6.0" pretty_assertions = "1.4" tempfile = "3" -[build-dependencies] -compile-time = "0.2" - [badges] maintenance = { status = "actively-developed" } @@ -16,7 +16,7 @@ debug: RUST_BACKTRACE=true cargo run --features=timing -- ${ARGS} build-release: - GITUI_RELEASE=1 cargo build --release --locked + cargo build --release --locked release-mac: build-release strip target/release/gitui @@ -42,7 +42,7 @@ build-linux-musl-debug: cargo build --target=x86_64-unknown-linux-musl build-linux-musl-release: - GITUI_RELEASE=1 cargo build --release --target=x86_64-unknown-linux-musl + cargo build --release --target=x86_64-unknown-linux-musl test-linux-musl: cargo test --workspace --target=x86_64-unknown-linux-musl @@ -64,9 +64,9 @@ build-linux-arm-debug: cargo build --target=arm-unknown-linux-gnueabihf build-linux-arm-release: - GITUI_RELEASE=1 cargo build --release --target=aarch64-unknown-linux-gnu - GITUI_RELEASE=1 cargo build --release --target=armv7-unknown-linux-gnueabihf - GITUI_RELEASE=1 cargo build --release --target=arm-unknown-linux-gnueabihf + cargo build --release --target=aarch64-unknown-linux-gnu + cargo build --release --target=armv7-unknown-linux-gnueabihf + cargo build --release --target=arm-unknown-linux-gnueabihf test: cargo test --workspace @@ -100,4 +100,4 @@ licenses: cargo bundle-licenses --format toml --output THIRDPARTY.toml clean: - cargo clean + cargo clean
\ No newline at end of file diff --git a/build.rs b/build.rs deleted file mode 100644 index 67ef0960..00000000 --- a/build.rs +++ /dev/null @@ -1,38 +0,0 @@ -fn get_git_hash() -> String { - use std::process::Command; - - let commit = Command::new("git") - .arg("rev-parse") - .arg("--short") - .arg("--verify") - .arg("HEAD") - .output(); - if let Ok(commit_output) = commit { - let commit_string = - String::from_utf8_lossy(&commit_output.stdout); - - return commit_string.lines().next().unwrap_or("").into(); - } - - panic!("Can not get git commit: {}", commit.unwrap_err()); -} - -fn main() { - let build_name = if std::env::var("GITUI_RELEASE").is_ok() { - format!( - "{} {} ({})", - env!("CARGO_PKG_VERSION"), - compile_time::date_str!(), - get_git_hash() - ) - } else { - format!( - "nightly {} ({})", - compile_time::date_str!(), - get_git_hash() - ) - }; - - println!("cargo:warning=buildname '{}'", build_name); - println!("cargo:rustc-env=GITUI_BUILD_NAME={}", build_name); -} diff --git a/src/args.rs b/src/args.rs index 74654220..2effe5fc 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, Arg, + crate_authors, crate_description, crate_name, crate_version, 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(env!("GITUI_BUILD_NAME")) + .version(crate_version!()) .about(crate_description!()) .help_template( "\ diff --git a/src/main.rs b/src/main.rs index 26093811..84a7a82e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,7 @@ 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 d472257a..9933d5c7 100644 --- a/src/popups/help.rs +++ b/src/popups/help.rs @@ -6,6 +6,7 @@ use crate::{ app::Environment, keys::{key_match, SharedKeyConfig}, strings, ui, + version::Version, }; use anyhow::Result; use asyncgit::hash; @@ -69,10 +70,7 @@ impl DrawableComponent for HelpPopup { f.render_widget( Paragraph::new(Line::from(vec![Span::styled( - Cow::from(format!( - "gitui {}", - env!("GITUI_BUILD_NAME"), - )), + Cow::from(format!("gitui {}", Version::new(),)), Style::default(), )])) .alignment(Alignment::Right), diff --git a/src/version.rs b/src/version.rs new file mode 100644 index 00000000..02af65c2 --- /dev/null +++ b/src/version.rs @@ -0,0 +1,35 @@ +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) + } +} |