Skip to content

Commit 4cc6b45

Browse files
committed
Revert "encode nightly version, commit, date into binary"
This reverts commit 89e9f85.
1 parent 89e9f85 commit 4cc6b45

File tree

8 files changed

+46
-84
lines changed

8 files changed

+46
-84
lines changed

Cargo.lock

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ readme = "README.md"
1212
license = "MIT"
1313
categories = ["command-line-utilities"]
1414
keywords = ["git", "gui", "cli", "terminal", "ui"]
15-
build = "build.rs"
1615

1716
[dependencies]
1817
anyhow = "1.0"
@@ -65,9 +64,6 @@ which = "6.0"
6564
pretty_assertions = "1.4"
6665
tempfile = "3"
6766

68-
[build-dependencies]
69-
compile-time = "0.2"
70-
7167
[badges]
7268
maintenance = { status = "actively-developed" }
7369

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ debug:
1616
RUST_BACKTRACE=true cargo run --features=timing -- ${ARGS}
1717

1818
build-release:
19-
GITUI_RELEASE=1 cargo build --release --locked
19+
cargo build --release --locked
2020

2121
release-mac: build-release
2222
strip target/release/gitui
@@ -42,7 +42,7 @@ build-linux-musl-debug:
4242
cargo build --target=x86_64-unknown-linux-musl
4343

4444
build-linux-musl-release:
45-
GITUI_RELEASE=1 cargo build --release --target=x86_64-unknown-linux-musl
45+
cargo build --release --target=x86_64-unknown-linux-musl
4646

4747
test-linux-musl:
4848
cargo test --workspace --target=x86_64-unknown-linux-musl
@@ -64,9 +64,9 @@ build-linux-arm-debug:
6464
cargo build --target=arm-unknown-linux-gnueabihf
6565

6666
build-linux-arm-release:
67-
GITUI_RELEASE=1 cargo build --release --target=aarch64-unknown-linux-gnu
68-
GITUI_RELEASE=1 cargo build --release --target=armv7-unknown-linux-gnueabihf
69-
GITUI_RELEASE=1 cargo build --release --target=arm-unknown-linux-gnueabihf
67+
cargo build --release --target=aarch64-unknown-linux-gnu
68+
cargo build --release --target=armv7-unknown-linux-gnueabihf
69+
cargo build --release --target=arm-unknown-linux-gnueabihf
7070

7171
test:
7272
cargo test --workspace
@@ -100,4 +100,4 @@ licenses:
100100
cargo bundle-licenses --format toml --output THIRDPARTY.toml
101101

102102
clean:
103-
cargo clean
103+
cargo clean

build.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::bug_report;
22
use anyhow::{anyhow, Result};
33
use asyncgit::sync::RepoPath;
44
use clap::{
5-
crate_authors, crate_description, crate_name, Arg,
5+
crate_authors, crate_description, crate_name, crate_version, Arg,
66
Command as ClapApp,
77
};
88
use simplelog::{Config, LevelFilter, WriteLogger};
@@ -63,7 +63,7 @@ pub fn process_cmdline() -> Result<CliArgs> {
6363
fn app() -> ClapApp {
6464
ClapApp::new(crate_name!())
6565
.author(crate_authors!())
66-
.version(env!("GITUI_BUILD_NAME"))
66+
.version(crate_version!())
6767
.about(crate_description!())
6868
.help_template(
6969
"\

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mod string_utils;
4343
mod strings;
4444
mod tabs;
4545
mod ui;
46+
mod version;
4647
mod watcher;
4748

4849
use crate::{app::App, args::process_cmdline};

src/popups/help.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
app::Environment,
77
keys::{key_match, SharedKeyConfig},
88
strings, ui,
9+
version::Version,
910
};
1011
use anyhow::Result;
1112
use asyncgit::hash;
@@ -69,10 +70,7 @@ impl DrawableComponent for HelpPopup {
6970

7071
f.render_widget(
7172
Paragraph::new(Line::from(vec![Span::styled(
72-
Cow::from(format!(
73-
"gitui {}",
74-
env!("GITUI_BUILD_NAME"),
75-
)),
73+
Cow::from(format!("gitui {}", Version::new(),)),
7674
Style::default(),
7775
)]))
7876
.alignment(Alignment::Right),

src/version.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::{env, fmt};
2+
3+
/// version type
4+
#[derive(Default)]
5+
pub struct Version {
6+
major: u32,
7+
minor: u32,
8+
patch: u32,
9+
}
10+
11+
impl Version {
12+
/// read version at compile time from env variables
13+
pub fn new() -> Self {
14+
let mut res = Self::default();
15+
let major_str = env!("CARGO_PKG_VERSION_MAJOR");
16+
if let Ok(major) = major_str.parse::<u32>() {
17+
res.major = major;
18+
}
19+
let minor_str = env!("CARGO_PKG_VERSION_MINOR");
20+
if let Ok(minor) = minor_str.parse::<u32>() {
21+
res.minor = minor;
22+
}
23+
let patch_str = env!("CARGO_PKG_VERSION_PATCH");
24+
if let Ok(patch) = patch_str.parse::<u32>() {
25+
res.patch = patch;
26+
}
27+
res
28+
}
29+
}
30+
31+
impl fmt::Display for Version {
32+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33+
write!(f, "v{}.{}.{}", self.major, self.minor, self.patch)
34+
}
35+
}

0 commit comments

Comments
 (0)