Skip to content

Commit 4e6bbd7

Browse files
committed
Auto merge of #6303 - integer32llc:open-ended-publish-warnings, r=alexcrichton
Support untyped warnings from registries with successful publish This adds a field "other" to the warnings deserialized from a successful publish response from a registry. This is [part of our plan to eventually require an email address to publish on crates.io to comply with DMCA](rust-lang/crates-io-cargo-teams#8). The TL;DR of that is we plan to warn for a release cycle when you publish without a verified email address once this change makes it to stable. I'm opting to add an "other" field rather than another field like the invalid badges/categories fields for a few reasons: - The warning we're planning on adding about emails will only exist for 6 weeks; those other warnings have happened in the past and will continue to happen. - There may be other transient warnings on publish that we'd like to send from crates.io in the future; it'd be nice to have a way of doing that without having to update cargo as well. - Other registries may have different warnings than we could ever anticipate in cargo; if usage of alternate registries grows, it'd be nice to give them a mechanism to warn as well. I've tested: - Cargo compiled with this change against a crates.io instance that doesn't return `other` warnings - Cargo compiled with this change against a crates.io instance that DOES return `other` warnings - Current Cargo against a crates.io instance that does return `other` warnings and they all behaved as I expected. I haven't added any tests because there aren't any tests that inject registry responses, and while I think cargo should have some of those eventually, I'm not going to add that infrastructure without discussing it with lots of folks first :) I know there's a soft feature freeze right now, buuuuut [it's wafer thin](https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fs4.thcdn.com%2Fproductimg%2F0%2F600%2F600%2F27%2F10284327-1288263770-74000.jpg&f=1)!! It doesn't add any surface area to the CLI or manifest format! ❤️
2 parents fba31ec + e66c413 commit 4e6bbd7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/cargo/ops/registry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ fn transmit(
276276
config.shell().warn(&msg)?;
277277
}
278278

279+
if !warnings.other.is_empty() {
280+
for msg in warnings.other {
281+
config.shell().warn(&msg)?;
282+
}
283+
}
284+
279285
Ok(())
280286
}
281287
Err(e) => Err(e),

src/crates-io/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub struct User {
8686
pub struct Warnings {
8787
pub invalid_categories: Vec<String>,
8888
pub invalid_badges: Vec<String>,
89+
pub other: Vec<String>,
8990
}
9091

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

227+
let other: Vec<String> = response
228+
.get("warnings")
229+
.and_then(|j| j.get("other"))
230+
.and_then(|j| j.as_array())
231+
.map(|x| x.iter().flat_map(|j| j.as_str()).map(Into::into).collect())
232+
.unwrap_or_else(Vec::new);
233+
226234
Ok(Warnings {
227235
invalid_categories,
228236
invalid_badges,
237+
other,
229238
})
230239
}
231240

0 commit comments

Comments
 (0)