mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-28 00:00:03 +00:00
Auto detect pkg_fmt
(#310)
* Refactor: Extract `GhCrateMeta::find_baseline` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Update `Cargo.lock`: Update dep `compact_str` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix use of `fetchers`: Set `meta.pkg_fmt` using `fetcher.pkg_fmt()` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Derive `strum_macors::{Display, EnumIter}` for `PkgFmt` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Set typeof field `PkgMeta::pkg_fmt` to be `Option<PkgFmt>` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize `Fetcher::new` to take `&Arc<Data>` instead of `&Data` To avoid unnecessary `Data::clone` call in `GhCrateMeta` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize `GhCrateMeta::find_baseline`: Avoid unnecessary spawning for `let Err(_) = url` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize spawning in `GhCrateMeta::find_baseline` Ret `Option<Url>` instead of `(Url, bool)` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add new method `target_meta` to trait `Fetcher` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Simplify `resolve_inner` using `Fetcher::target_meta` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize loop in `resolve_inner`: Avoid cloning `PkgOverride` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Impl `PkgMeta::clone_without_overrides` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize `resolve_inner` loop: Use `PkgMeta::clone_without_overrides` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Refactor: Simplify `Context::from_data` impl Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Refactor: Extract `launch_baseline_find_tasks` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Refactor: Simplify `<GhCrateMeta as Fetcher>::find` Instead of launching tasks in an opaque manner in `Self::find_baseline`, the new design returns an iterator which launches the tasks and thus have a unified `.await` point for all these tasks. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add `warn!`ing to report failure of `Context::render_url` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
b5ea9a2293
commit
6b5e8f6875
8 changed files with 106 additions and 66 deletions
|
@ -37,7 +37,7 @@ pub struct PkgMeta {
|
|||
pub pkg_url: String,
|
||||
|
||||
/// Format for package downloads
|
||||
pub pkg_fmt: PkgFmt,
|
||||
pub pkg_fmt: Option<PkgFmt>,
|
||||
|
||||
/// Path template for binary files in packages
|
||||
pub bin_dir: String,
|
||||
|
@ -53,7 +53,7 @@ impl Default for PkgMeta {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
pkg_url: DEFAULT_PKG_URL.to_string(),
|
||||
pkg_fmt: PkgFmt::default(),
|
||||
pkg_fmt: None,
|
||||
bin_dir: DEFAULT_BIN_DIR.to_string(),
|
||||
pub_key: None,
|
||||
overrides: HashMap::new(),
|
||||
|
@ -62,13 +62,23 @@ impl Default for PkgMeta {
|
|||
}
|
||||
|
||||
impl PkgMeta {
|
||||
pub fn clone_without_overrides(&self) -> Self {
|
||||
Self {
|
||||
pkg_url: self.pkg_url.clone(),
|
||||
pkg_fmt: self.pkg_fmt,
|
||||
bin_dir: self.bin_dir.clone(),
|
||||
pub_key: self.pub_key.clone(),
|
||||
overrides: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Merge configuration overrides into object
|
||||
pub fn merge(&mut self, pkg_override: &PkgOverride) {
|
||||
if let Some(o) = &pkg_override.pkg_url {
|
||||
self.pkg_url = o.clone();
|
||||
}
|
||||
if let Some(o) = &pkg_override.pkg_fmt {
|
||||
self.pkg_fmt = *o;
|
||||
self.pkg_fmt = Some(*o);
|
||||
}
|
||||
if let Some(o) = &pkg_override.bin_dir {
|
||||
self.bin_dir = o.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue