From: Carol (Nichols || Goulding) Date: Mon, 5 Dec 2016 17:36:44 +0000 (-0500) Subject: Add more structure to the warnings returned from crates.io publish X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~11^2~34^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f697b8c68d56fb2acb66accacb449b7bcb49d838;p=cargo.git Add more structure to the warnings returned from crates.io publish --- diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 2b4447609..4c9bad817 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -151,13 +151,13 @@ fn transmit(config: &Config, }, tarball); match publish { - Ok(invalid_categories) => { - if !invalid_categories.is_empty() { + Ok(warnings) => { + if !warnings.invalid_categories.is_empty() { let msg = format!("\ the following are not valid category slugs and were \ ignored: {}. Please see https://crates.io/category_slugs \ for the list of all category slugs. \ - ", invalid_categories.join(", ")); + ", warnings.invalid_categories.join(", ")); config.shell().warn(&msg)?; } Ok(()) diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index e35d82440..00637be3d 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -111,6 +111,10 @@ pub struct User { pub name: Option, } +pub struct Warnings { + pub invalid_categories: Vec, +} + #[derive(RustcDecodable)] struct R { ok: bool } #[derive(RustcDecodable)] struct ApiErrorList { errors: Vec } #[derive(RustcDecodable)] struct ApiError { detail: String } @@ -155,7 +159,7 @@ impl Registry { } pub fn publish(&mut self, krate: &NewCrate, tarball: &File) - -> Result> { + -> Result { let json = json::encode(krate)?; // Prepare the body. The format of the upload request is: // @@ -215,7 +219,7 @@ impl Registry { x.iter().flat_map(Json::as_string).map(Into::into).collect() }) .unwrap_or_else(Vec::new); - Ok(invalid_categories) + Ok(Warnings { invalid_categories: invalid_categories }) } pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec, u32)> {