mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-28 00:00:03 +00:00
Support other git hosting services (#312)
* Impl new mod `hosting` for detecting git hosting services * Refactor: Make `guess_git_hosting_services` associated fn of `GitHostingService` * Set default value of `PkgMeta::pkg_url` to `None` * Impl new method `get_redirected_final_url` * Use `get_redirected_final_url` in `GhCrateMeta::find` to make `guess_git_hosting_services` more accurate. * Use redirected `repo` in `GhCrateMeta::launch_baseline_find_tasks` * Refactor `<GhCrateMeta as Fetcher>::find` * Mod `get_default_pkg_url_template` to ret `&[&str]` * Add more default `pkg-url` templates * Rm `pkg-url` in `bin/Cargo.toml` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
6b5e8f6875
commit
846e7ead91
7 changed files with 251 additions and 44 deletions
|
@ -11,10 +11,6 @@ pub use package_formats::*;
|
|||
|
||||
mod package_formats;
|
||||
|
||||
/// Default package path template (may be overridden in package Cargo.toml)
|
||||
pub const DEFAULT_PKG_URL: &str =
|
||||
"{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.{ archive-format }";
|
||||
|
||||
/// Default binary name template (may be overridden in package Cargo.toml)
|
||||
pub const DEFAULT_BIN_DIR: &str = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }";
|
||||
|
||||
|
@ -34,7 +30,7 @@ pub struct Meta {
|
|||
#[serde(rename_all = "kebab-case", default)]
|
||||
pub struct PkgMeta {
|
||||
/// URL template for package downloads
|
||||
pub pkg_url: String,
|
||||
pub pkg_url: Option<String>,
|
||||
|
||||
/// Format for package downloads
|
||||
pub pkg_fmt: Option<PkgFmt>,
|
||||
|
@ -52,7 +48,7 @@ pub struct PkgMeta {
|
|||
impl Default for PkgMeta {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pkg_url: DEFAULT_PKG_URL.to_string(),
|
||||
pkg_url: None,
|
||||
pkg_fmt: None,
|
||||
bin_dir: DEFAULT_BIN_DIR.to_string(),
|
||||
pub_key: None,
|
||||
|
@ -75,7 +71,7 @@ impl PkgMeta {
|
|||
/// 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();
|
||||
self.pkg_url = Some(o.clone());
|
||||
}
|
||||
if let Some(o) = &pkg_override.pkg_fmt {
|
||||
self.pkg_fmt = Some(*o);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue