Skip to content

Commit

Permalink
Merge pull request #26 from paritytech/oty-error-logs
Browse files Browse the repository at this point in the history
Enable stable patches
  • Loading branch information
ggwpez authored Sep 6, 2024
2 parents 2bd5044 + b74e436 commit e5a6dec
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,17 @@ pub async fn get_version_mapping_with_fallback(
) -> Result<BTreeMap<String, String>, Box<dyn std::error::Error>> {
let result = get_version_mapping(base_url, version, "Plan.toml").await;

if result.is_err() {
println!("Failed to get Plan.toml, falling back to Cargo.lock.");
get_version_mapping(base_url, version, "Cargo.lock").await
} else {
result
match result {
Err(_) => get_version_mapping(base_url, version, "Cargo.lock").await,
Ok(_) => result
}
}

fn version_to_url(base_url: &str, version: &str, source: &str) -> String {
let stable_tag_regex_patten = Regex::new(POLKADOT_SDK_STABLE_TAGS_REGEX).unwrap();
let version = if version.starts_with("stable") || stable_tag_regex_patten.is_match(version) {
let version = if version.starts_with("stable") {
format!("polkadot-{}", version)
} else if stable_tag_regex_patten.is_match(version) {
version.into()
} else {
format!("release-crates-io-v{}", version)
Expand All @@ -327,7 +327,11 @@ pub async fn get_version_mapping(
.header("Accept", "application/vnd.github.v3+json")
.send()
.await?;
let content = response.text().await?;

let content = match response.error_for_status() {
Ok(response) => response.text().await?,
Err(err) => return Err(err.into()),
};

match source {
"Cargo.lock" => get_cargo_packages(&content),
Expand Down

0 comments on commit e5a6dec

Please sign in to comment.