package_info: fix check_launchpad_repo needing web requests (use git)
This commit is contained in:
@@ -20,15 +20,15 @@ pub fn ppa_to_base_url(user: &str, name: &str) -> String {
|
||||
|
||||
async fn check_launchpad_repo(package: &str) -> Result<Option<String>, Box<dyn Error>> {
|
||||
let url = format!("https://git.launchpad.net/ubuntu/+source/{}", package);
|
||||
let client = reqwest::Client::builder()
|
||||
.redirect(reqwest::redirect::Policy::none())
|
||||
.build()?;
|
||||
let response = client.head(&url).send().await?;
|
||||
|
||||
if response.status().is_success() {
|
||||
Ok(Some(url))
|
||||
} else {
|
||||
Ok(None)
|
||||
// Use libgit2 to check if the remote repository exists
|
||||
// This is more reliable than HTTP HEAD requests when CGIt is disabled
|
||||
match git2::Remote::create_detached(url.clone()) {
|
||||
Ok(mut remote) => match remote.connect(git2::Direction::Fetch) {
|
||||
Ok(_) => Ok(Some(url)),
|
||||
Err(_) => Ok(None),
|
||||
},
|
||||
Err(_) => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user