mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(publish): Show remaining packages to be published
This commit is contained in:
parent
f36cb83e98
commit
d2a6dcb43e
@ -210,7 +210,8 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
|
||||
// `b`, and we uploaded `a` and `b` but only confirmed `a`, then on
|
||||
// the following pass through the outer loop nothing will be ready for
|
||||
// upload.
|
||||
for pkg_id in plan.take_ready() {
|
||||
let mut ready = plan.take_ready();
|
||||
while let Some(pkg_id) = ready.pop_first() {
|
||||
let (pkg, (_features, tarball)) = &pkg_dep_graph.packages[&pkg_id];
|
||||
opts.gctx.shell().status("Uploading", pkg.package_id())?;
|
||||
|
||||
@ -236,6 +237,19 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
|
||||
)?));
|
||||
}
|
||||
|
||||
let workspace_context = || {
|
||||
let mut remaining = ready.clone();
|
||||
remaining.extend(plan.iter());
|
||||
if !remaining.is_empty() {
|
||||
format!(
|
||||
"\n\nnote: the following crates have not been published yet:\n {}",
|
||||
remaining.into_iter().join("\n ")
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
};
|
||||
|
||||
transmit(
|
||||
opts.gctx,
|
||||
ws,
|
||||
@ -244,6 +258,7 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
|
||||
&mut registry,
|
||||
source_ids.original,
|
||||
opts.dry_run,
|
||||
workspace_context,
|
||||
)?;
|
||||
to_confirm.insert(pkg_id);
|
||||
|
||||
@ -632,6 +647,7 @@ fn transmit(
|
||||
registry: &mut Registry,
|
||||
registry_id: SourceId,
|
||||
dry_run: bool,
|
||||
workspace_context: impl Fn() -> String,
|
||||
) -> CargoResult<()> {
|
||||
let new_crate = prepare_transmit(gctx, ws, pkg, registry_id)?;
|
||||
|
||||
@ -643,10 +659,11 @@ fn transmit(
|
||||
|
||||
let warnings = registry.publish(&new_crate, tarball).with_context(|| {
|
||||
format!(
|
||||
"failed to publish {} v{} to registry at {}",
|
||||
"failed to publish {} v{} to registry at {}{}",
|
||||
pkg.name(),
|
||||
pkg.version(),
|
||||
registry.host()
|
||||
registry.host(),
|
||||
workspace_context()
|
||||
)
|
||||
})?;
|
||||
|
||||
|
@ -4474,8 +4474,8 @@ fn workspace_publish_rate_limit_error() {
|
||||
.file("package_c/src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
// This demonstrates the current non-actionable error message
|
||||
// The user doesn't know which package failed or what packages remain to be published
|
||||
// This demonstrates the improved error message after the fix
|
||||
// The user now knows which package failed and what packages remain to be published
|
||||
p.cargo("publish --workspace --no-verify")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.with_status(101)
|
||||
@ -4491,6 +4491,10 @@ fn workspace_publish_rate_limit_error() {
|
||||
[UPLOADING] package_a v0.1.0 ([ROOT]/foo/package_a)
|
||||
[ERROR] failed to publish package_a v0.1.0 to registry at http://127.0.0.1:[..]/
|
||||
|
||||
[NOTE] the following crates have not been published yet:
|
||||
package_b v0.1.0 ([ROOT]/foo/package_b)
|
||||
package_c v0.1.0 ([ROOT]/foo/package_c)
|
||||
|
||||
Caused by:
|
||||
failed to get a 200 OK response, got 429
|
||||
headers:
|
||||
|
Loading…
x
Reference in New Issue
Block a user