Skip to content

Commit

Permalink
Revert "fix: proxy version comparison" (#2395)
Browse files Browse the repository at this point in the history
This reverts commit b35b42a.
  • Loading branch information
panekj committed May 22, 2023
1 parent b35b42a commit e7f9261
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 60 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ clap = { version = "3.2.17", features = ["derive"] }
crossbeam-channel = "0.5.0"
directories = "4.0.1"
flate2 = "1.0"
git2 = { version = "0.16.1", features = ["vendored-openssl"] }
hashbrown = { version = "0.12.3", features = ["serde"] }
im = { version = "15.0.0", features = ["serde"] }
include_dir = "0.6.2"
Expand Down
2 changes: 1 addition & 1 deletion extra/proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ eval lapce_dir="'${2}'"
if [ -e "${lapce_dir}/lapce" ]; then
chmod +x "${lapce_dir}/lapce"

lapce_installed_ver=$("${lapce_dir}/lapce" --version | cut -d' ' -f2)
lapce_installed_ver=$("${lapce_dir}/lapce" --version | cut -d'v' -f2)

printf '[DEBUG]: Current proxy version: %s\n' "${lapce_installed_ver}"
printf '[DEBUG]: New proxy version: %s\n' "${lapce_new_ver}"
Expand Down
1 change: 0 additions & 1 deletion lapce-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,3 @@ lang-zig = ["dep:tree-sitter-zig"]

[build-dependencies]
anyhow.workspace = true
git2.workspace = true
58 changes: 11 additions & 47 deletions lapce-core/build.rs
Original file line number Diff line number Diff line change
@@ -1,75 +1,39 @@
#![allow(clippy::redundant_clone)]
use std::{env, fs, path::Path};

use anyhow::Result;

#[cfg(not(debug_assertions))]
const RELEASE_TYPE: &str = "Nightly";

#[cfg(debug_assertions)]
const RELEASE_TYPE: &str = "Debug";

fn main() -> Result<()> {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=RELEASE_TAG_NAME");
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");

let (tag, release, version, commit, full_version) = {
#[cfg(not(debug_assertions))]
let (tag, release, version) = {
let tag = env::var("RELEASE_TAG_NAME").unwrap_or(String::from("nightly"));

if tag.starts_with('v') {
(
tag.clone(),
"Stable",
env::var("CARGO_PKG_VERSION")?,
git2::Oid::zero(),
tag.clone(),
)
let (release, version) = if tag.starts_with('v') {
("Stable", env::var("CARGO_PKG_VERSION")?)
} else {
let (commit, full_version) = match get_commit() {
Some(id) => (id, format!("{tag}-{} {id}", &id.to_string()[..7])),
None => (git2::Oid::zero(), tag.to_string()),
};
("Nightly", tag.clone())
};

(tag.clone(), RELEASE_TYPE, tag.clone(), commit, full_version)
}
(tag, release, version)
};

#[cfg(debug_assertions)]
let (tag, release, version) = (String::new(), "Debug", String::from("debug"));

let meta_file = Path::new(&env::var("OUT_DIR")?).join("meta.rs");

#[rustfmt::skip]
let meta = format!(r#"
pub const TAG: &str = "{tag}";
pub const COMMIT: &str = "{commit}";
pub const VERSION: &str = "{version}";
pub const FULL_VERSION: &str = "{full_version}";
pub const NAME: &str = "Lapce-{release}";
pub const VERSION: &str = "{version}";
pub const RELEASE: ReleaseType = ReleaseType::{release};
"#);

fs::write(meta_file, meta)?;

Ok(())
}

fn get_commit() -> Option<git2::Oid> {
if let Ok(repo) = git2::Repository::discover(".") {
if let Ok(head) = repo.find_reference("HEAD") {
let path = repo.path().to_path_buf();

if let Ok(resolved) = head.resolve() {
if let Some(name) = resolved.name() {
let path = path.join(name);
if path.exists() {
println!(
"cargo:rerun-if-changed={}",
path.canonicalize().unwrap().display()
);
}
}
return Some(resolved.peel_to_commit().ok()?.id());
}
}
}
None
}
2 changes: 1 addition & 1 deletion lapce-data/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ impl LapceTabData {
match command {
LapceWorkbenchCommand::RestartToUpdate => {
if let Some(release) = (*self.latest_release).clone() {
if release.version != *meta::TAG {
if release.version != *meta::VERSION {
if let Ok(process_path) = env::current_exe() {
ctx.submit_command(Command::new(
LAPCE_UI_COMMAND,
Expand Down
2 changes: 1 addition & 1 deletion lapce-data/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn get_latest_release() -> Result<ReleaseInfo> {

release.version = match release.tag_name.as_str() {
"nightly" => format!("nightly-{}", &release.target_commitish[..7]),
_ => release.tag_name.to_owned(),
_ => release.tag_name[1..].to_string(),
};

Ok(release)
Expand Down
6 changes: 4 additions & 2 deletions lapce-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ clap.workspace = true
crossbeam-channel.workspace = true
directories.workspace = true
flate2.workspace = true
git2.workspace = true
indexmap.workspace = true
interprocess.workspace = true
log.workspace = true
Expand Down Expand Up @@ -49,6 +48,9 @@ jsonrpc-lite = "0.6.0"
# finding terminal shell
which = "4.2.5"

# git
git2 = { version = "0.16.1", features = ["vendored-openssl"] }

# deleting files
trash = "2.1.5"

Expand All @@ -70,4 +72,4 @@ git = "https://github.com/lapce/wasi-experimental-http"
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.24"
objc = "0.2"
libc = "0.2"
libc = "0.2"
2 changes: 1 addition & 1 deletion lapce-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use lapce_rpc::{

#[derive(Parser)]
#[clap(name = meta::NAME)]
#[clap(version = meta::FULL_VERSION)]
#[clap(version = meta::VERSION)]
struct Cli {
#[clap(short, long, action, hide = true)]
proxy: bool,
Expand Down
2 changes: 1 addition & 1 deletion lapce-ui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{

#[derive(Parser)]
#[clap(name = meta::NAME)]
#[clap(version = meta::FULL_VERSION)]
#[clap(version = meta::VERSION)]
#[derive(Debug)]
struct Cli {
/// Launch new window even if Lapce is already running
Expand Down
6 changes: 3 additions & 3 deletions lapce-ui/src/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl Title {
desc: Some(if data.update_in_progress && latest_version.is_some() {
format!("Update in progress ({}) ", latest_version.unwrap())
} else if latest_version.is_some()
&& latest_version != Some(meta::TAG)
&& latest_version != Some(meta::VERSION)
{
format!("Restart to update ({})", latest_version.unwrap())
} else {
Expand All @@ -422,7 +422,7 @@ impl Title {
data: None,
},
enabled: latest_version.is_some()
&& latest_version != Some(meta::TAG)
&& latest_version != Some(meta::VERSION)
&& !data.update_in_progress,
}),
MenuKind::Separator,
Expand All @@ -435,7 +435,7 @@ impl Title {
enabled: true,
}),
];
if latest_version.is_some() && latest_version != Some(meta::TAG) {
if latest_version.is_some() && latest_version != Some(meta::VERSION) {
let text_layout = piet_text
.new_text_layout("1")
.font(data.config.ui.font_family(), 10.0)
Expand Down

0 comments on commit e7f9261

Please sign in to comment.