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:
Jiahao XU 2022-08-24 17:16:26 +10:00 committed by GitHub
parent 6b5e8f6875
commit 846e7ead91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 251 additions and 44 deletions

View file

@ -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,