Skip to content

Commit

Permalink
Support untyped warnings from crates.io with successful publish
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Nov 10, 2018
1 parent ab59c81 commit e66c413
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ fn transmit(
config.shell().warn(&msg)?;
}

if !warnings.other.is_empty() {
for msg in warnings.other {
config.shell().warn(&msg)?;
}
}

Ok(())
}
Err(e) => Err(e),
Expand Down
9 changes: 9 additions & 0 deletions src/crates-io/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub struct User {
pub struct Warnings {
pub invalid_categories: Vec<String>,
pub invalid_badges: Vec<String>,
pub other: Vec<String>,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -223,9 +224,17 @@ impl Registry {
.map(|x| x.iter().flat_map(|j| j.as_str()).map(Into::into).collect())
.unwrap_or_else(Vec::new);

let other: Vec<String> = response
.get("warnings")
.and_then(|j| j.get("other"))
.and_then(|j| j.as_array())
.map(|x| x.iter().flat_map(|j| j.as_str()).map(Into::into).collect())
.unwrap_or_else(Vec::new);

Ok(Warnings {
invalid_categories,
invalid_badges,
other,
})
}

Expand Down

0 comments on commit e66c413

Please sign in to comment.