mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-05 19:50:02 +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
|
@ -42,6 +42,19 @@ pub async fn remote_exists(
|
|||
Ok(req.status().is_success())
|
||||
}
|
||||
|
||||
pub async fn get_redirected_final_url(client: &Client, url: Url) -> Result<Url, BinstallError> {
|
||||
let method = Method::HEAD;
|
||||
|
||||
let req = client
|
||||
.request(method.clone(), url.clone())
|
||||
.send()
|
||||
.await
|
||||
.and_then(Response::error_for_status)
|
||||
.map_err(|err| BinstallError::Http { method, url, err })?;
|
||||
|
||||
Ok(req.url().clone())
|
||||
}
|
||||
|
||||
pub(crate) async fn create_request(
|
||||
client: &Client,
|
||||
url: Url,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue