-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fix: proxy version comparison" (#2395)
This reverts commit b35b42a.
- Loading branch information
Showing
11 changed files
with
23 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,4 +144,3 @@ lang-zig = ["dep:tree-sitter-zig"] | |
|
||
[build-dependencies] | ||
anyhow.workspace = true | ||
git2.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters