Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload categories specified in the manifest #3301

Merged
merged 4 commits into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add more structure to the warnings returned from crates.io publish
  • Loading branch information
carols10cents committed Dec 5, 2016
commit f697b8c68d56fb2acb66accacb449b7bcb49d838
6 changes: 3 additions & 3 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
8 changes: 6 additions & 2 deletions src/crates-io/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ pub struct User {
pub name: Option<String>,
}

pub struct Warnings {
pub invalid_categories: Vec<String>,
}

#[derive(RustcDecodable)] struct R { ok: bool }
#[derive(RustcDecodable)] struct ApiErrorList { errors: Vec<ApiError> }
#[derive(RustcDecodable)] struct ApiError { detail: String }
Expand Down Expand Up @@ -155,7 +159,7 @@ impl Registry {
}

pub fn publish(&mut self, krate: &NewCrate, tarball: &File)
-> Result<Vec<String>> {
-> Result<Warnings> {
let json = json::encode(krate)?;
// Prepare the body. The format of the upload request is:
//
Expand Down Expand Up @@ -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<Crate>, u32)> {
Expand Down