Skip to content

Commit 94f1f07

Browse files
committed
Bump to 2.0.0-alpha.1 & fix version checks
1 parent f5b5a61 commit 94f1f07

File tree

9 files changed

+43
-31
lines changed

9 files changed

+43
-31
lines changed

Cargo.lock

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

objdiff-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "objdiff-cli"
3-
version = "0.1.0"
3+
version = "2.0.0-alpha.1"
44
edition = "2021"
55
rust-version = "1.70"
66
authors = ["Luke Street <[email protected]>"]

objdiff-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "objdiff-core"
3-
version = "1.0.0"
3+
version = "2.0.0-alpha.1"
44
edition = "2021"
55
rust-version = "1.70"
66
authors = ["Luke Street <[email protected]>"]

objdiff-core/src/config/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ fn validate_min_version(config: &ProjectConfig) -> Result<()> {
143143
let Some(min_version) = &config.min_version else { return Ok(()) };
144144
let version = semver::Version::parse(env!("CARGO_PKG_VERSION"))
145145
.context("Failed to parse package version")?;
146-
match semver::VersionReq::parse(&format!(">={min_version}")) {
147-
Ok(version_req) if version_req.matches(&version) => Ok(()),
148-
Ok(_) => Err(anyhow!("Project requires objdiff version {min_version} or higher")),
149-
Err(e) => Err(anyhow::Error::new(e).context("Failed to parse min_version")),
146+
let min_version = semver::Version::parse(min_version).context("Failed to parse min_version")?;
147+
if version >= min_version {
148+
Ok(())
149+
} else {
150+
Err(anyhow!("Project requires objdiff version {min_version} or higher"))
150151
}
151152
}
152153

objdiff-gui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "objdiff-gui"
3-
version = "1.0.0"
3+
version = "2.0.0-alpha.1"
44
edition = "2021"
55
rust-version = "1.70"
66
authors = ["Luke Street <[email protected]>"]

objdiff-gui/src/jobs/check_update.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use self_update::{cargo_crate_version, update::Release};
55

66
use crate::{
77
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
8-
update::{build_updater, BIN_NAME},
8+
update::{build_updater, BIN_NAME_NEW, BIN_NAME_OLD},
99
};
1010

1111
pub struct CheckUpdateResult {
1212
pub update_available: bool,
1313
pub latest_release: Release,
14-
pub found_binary: bool,
14+
pub found_binary: Option<String>,
1515
}
1616

1717
fn run_check_update(context: &JobContext, cancel: Receiver<()>) -> Result<Box<CheckUpdateResult>> {
@@ -20,7 +20,13 @@ fn run_check_update(context: &JobContext, cancel: Receiver<()>) -> Result<Box<Ch
2020
let latest_release = updater.get_latest_release()?;
2121
let update_available =
2222
self_update::version::bump_is_greater(cargo_crate_version!(), &latest_release.version)?;
23-
let found_binary = latest_release.assets.iter().any(|a| a.name == BIN_NAME);
23+
// Find the binary name in the release assets
24+
let found_binary = latest_release
25+
.assets
26+
.iter()
27+
.find(|a| a.name == BIN_NAME_NEW)
28+
.or_else(|| latest_release.assets.iter().find(|a| a.name == BIN_NAME_OLD))
29+
.map(|a| a.name.clone());
2430

2531
update_status(context, "Complete".to_string(), 1, 1, &cancel)?;
2632
Ok(Box::new(CheckUpdateResult { update_available, latest_release, found_binary }))

objdiff-gui/src/jobs/update.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,29 @@ use std::{
66
};
77

88
use anyhow::{Context, Result};
9-
use const_format::formatcp;
109

1110
use crate::{
1211
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
13-
update::{build_updater, BIN_NAME},
12+
update::build_updater,
1413
};
1514

1615
pub struct UpdateResult {
1716
pub exe_path: PathBuf,
1817
}
1918

20-
fn run_update(status: &JobContext, cancel: Receiver<()>) -> Result<Box<UpdateResult>> {
19+
fn run_update(
20+
status: &JobContext,
21+
cancel: Receiver<()>,
22+
bin_name: String,
23+
) -> Result<Box<UpdateResult>> {
2124
update_status(status, "Fetching latest release".to_string(), 0, 3, &cancel)?;
2225
let updater = build_updater().context("Failed to create release updater")?;
2326
let latest_release = updater.get_latest_release()?;
2427
let asset = latest_release
2528
.assets
2629
.iter()
27-
.find(|a| a.name == BIN_NAME)
28-
.ok_or_else(|| anyhow::Error::msg(formatcp!("No release asset for {}", BIN_NAME)))?;
30+
.find(|a| a.name == bin_name)
31+
.ok_or_else(|| anyhow::Error::msg(format!("No release asset for {bin_name}")))?;
2932

3033
update_status(status, "Downloading release".to_string(), 1, 3, &cancel)?;
3134
let tmp_dir = tempfile::Builder::new().prefix("update").tempdir_in(current_dir()?)?;
@@ -53,8 +56,8 @@ fn run_update(status: &JobContext, cancel: Receiver<()>) -> Result<Box<UpdateRes
5356
Ok(Box::from(UpdateResult { exe_path: target_file }))
5457
}
5558

56-
pub fn start_update(ctx: &egui::Context) -> JobState {
59+
pub fn start_update(ctx: &egui::Context, bin_name: String) -> JobState {
5760
start_job(ctx, "Update app", Job::Update, move |context, cancel| {
58-
run_update(&context, cancel).map(JobResult::Update)
61+
run_update(&context, cancel, bin_name).map(JobResult::Update)
5962
})
6063
}

objdiff-gui/src/update.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ cfg_if! {
2020
}
2121
pub const GITHUB_USER: &str = "encounter";
2222
pub const GITHUB_REPO: &str = "objdiff";
23-
pub const BIN_NAME: &str =
24-
formatcp!("{}-{}-{}{}", GITHUB_REPO, OS, ARCH, std::env::consts::EXE_SUFFIX);
23+
pub const BIN_NAME_NEW: &str =
24+
formatcp!("objdiff-gui-{}-{}{}", OS, ARCH, std::env::consts::EXE_SUFFIX);
25+
pub const BIN_NAME_OLD: &str = formatcp!("objdiff-{}-{}{}", OS, ARCH, std::env::consts::EXE_SUFFIX);
2526
pub const RELEASE_URL: &str =
2627
formatcp!("https://github.com/{}/{}/releases/latest", GITHUB_USER, GITHUB_REPO);
2728

2829
pub fn build_updater() -> self_update::errors::Result<Box<dyn ReleaseUpdate>> {
2930
self_update::backends::github::Update::configure()
3031
.repo_owner(GITHUB_USER)
3132
.repo_name(GITHUB_REPO)
32-
.bin_name(BIN_NAME)
33+
// bin_name is required, but unused?
34+
.bin_name(BIN_NAME_NEW)
3335
.no_confirm(true)
3436
.show_output(false)
3537
.current_version(cargo_crate_version!())

objdiff-gui/src/views/config.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct ConfigViewState {
4141
pub check_update_running: bool,
4242
pub queue_check_update: bool,
4343
pub update_running: bool,
44-
pub queue_update: bool,
44+
pub queue_update: Option<String>,
4545
pub build_running: bool,
4646
pub queue_build: bool,
4747
pub watch_pattern_text: String,
@@ -127,9 +127,8 @@ impl ConfigViewState {
127127
jobs.push_once(Job::CheckUpdate, || start_check_update(ctx));
128128
}
129129

130-
if self.queue_update {
131-
self.queue_update = false;
132-
jobs.push_once(Job::Update, || start_update(ctx));
130+
if let Some(bin_name) = self.queue_update.take() {
131+
jobs.push_once(Job::Update, || start_update(ctx, bin_name));
133132
}
134133
}
135134
}
@@ -201,15 +200,16 @@ pub fn config_ui(
201200
if result.update_available {
202201
ui.colored_label(appearance.insert_color, "Update available");
203202
ui.horizontal(|ui| {
204-
if result.found_binary
205-
&& ui
203+
if let Some(bin_name) = &result.found_binary {
204+
if ui
206205
.add_enabled(!state.update_running, egui::Button::new("Automatic"))
207206
.on_hover_text_at_pointer(
208207
"Automatically download and replace the current build",
209208
)
210209
.clicked()
211-
{
212-
state.queue_update = true;
210+
{
211+
state.queue_update = Some(bin_name.clone());
212+
}
213213
}
214214
if ui
215215
.button("Manual")

0 commit comments

Comments
 (0)