Skip to content

Commit f697b8c

Browse files
committed
Add more structure to the warnings returned from crates.io publish
1 parent 7dd0f93 commit f697b8c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/cargo/ops/registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ fn transmit(config: &Config,
151151
}, tarball);
152152

153153
match publish {
154-
Ok(invalid_categories) => {
155-
if !invalid_categories.is_empty() {
154+
Ok(warnings) => {
155+
if !warnings.invalid_categories.is_empty() {
156156
let msg = format!("\
157157
the following are not valid category slugs and were \
158158
ignored: {}. Please see https://crates.io/category_slugs \
159159
for the list of all category slugs. \
160-
", invalid_categories.join(", "));
160+
", warnings.invalid_categories.join(", "));
161161
config.shell().warn(&msg)?;
162162
}
163163
Ok(())

src/crates-io/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ pub struct User {
111111
pub name: Option<String>,
112112
}
113113

114+
pub struct Warnings {
115+
pub invalid_categories: Vec<String>,
116+
}
117+
114118
#[derive(RustcDecodable)] struct R { ok: bool }
115119
#[derive(RustcDecodable)] struct ApiErrorList { errors: Vec<ApiError> }
116120
#[derive(RustcDecodable)] struct ApiError { detail: String }
@@ -155,7 +159,7 @@ impl Registry {
155159
}
156160

157161
pub fn publish(&mut self, krate: &NewCrate, tarball: &File)
158-
-> Result<Vec<String>> {
162+
-> Result<Warnings> {
159163
let json = json::encode(krate)?;
160164
// Prepare the body. The format of the upload request is:
161165
//
@@ -215,7 +219,7 @@ impl Registry {
215219
x.iter().flat_map(Json::as_string).map(Into::into).collect()
216220
})
217221
.unwrap_or_else(Vec::new);
218-
Ok(invalid_categories)
222+
Ok(Warnings { invalid_categories: invalid_categories })
219223
}
220224

221225
pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec<Crate>, u32)> {

0 commit comments

Comments
 (0)