Skip to content

Commit d2a6dcb

Browse files
ojuschugh1epage
authored andcommitted
fix(publish): Show remaining packages to be published
1 parent f36cb83 commit d2a6dcb

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/cargo/ops/registry/publish.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
210210
// `b`, and we uploaded `a` and `b` but only confirmed `a`, then on
211211
// the following pass through the outer loop nothing will be ready for
212212
// upload.
213-
for pkg_id in plan.take_ready() {
213+
let mut ready = plan.take_ready();
214+
while let Some(pkg_id) = ready.pop_first() {
214215
let (pkg, (_features, tarball)) = &pkg_dep_graph.packages[&pkg_id];
215216
opts.gctx.shell().status("Uploading", pkg.package_id())?;
216217

@@ -236,6 +237,19 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
236237
)?));
237238
}
238239

240+
let workspace_context = || {
241+
let mut remaining = ready.clone();
242+
remaining.extend(plan.iter());
243+
if !remaining.is_empty() {
244+
format!(
245+
"\n\nnote: the following crates have not been published yet:\n {}",
246+
remaining.into_iter().join("\n ")
247+
)
248+
} else {
249+
String::new()
250+
}
251+
};
252+
239253
transmit(
240254
opts.gctx,
241255
ws,
@@ -244,6 +258,7 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
244258
&mut registry,
245259
source_ids.original,
246260
opts.dry_run,
261+
workspace_context,
247262
)?;
248263
to_confirm.insert(pkg_id);
249264

@@ -632,6 +647,7 @@ fn transmit(
632647
registry: &mut Registry,
633648
registry_id: SourceId,
634649
dry_run: bool,
650+
workspace_context: impl Fn() -> String,
635651
) -> CargoResult<()> {
636652
let new_crate = prepare_transmit(gctx, ws, pkg, registry_id)?;
637653

@@ -643,10 +659,11 @@ fn transmit(
643659

644660
let warnings = registry.publish(&new_crate, tarball).with_context(|| {
645661
format!(
646-
"failed to publish {} v{} to registry at {}",
662+
"failed to publish {} v{} to registry at {}{}",
647663
pkg.name(),
648664
pkg.version(),
649-
registry.host()
665+
registry.host(),
666+
workspace_context()
650667
)
651668
})?;
652669

tests/testsuite/publish.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,8 +4474,8 @@ fn workspace_publish_rate_limit_error() {
44744474
.file("package_c/src/lib.rs", "")
44754475
.build();
44764476

4477-
// This demonstrates the current non-actionable error message
4478-
// The user doesn't know which package failed or what packages remain to be published
4477+
// This demonstrates the improved error message after the fix
4478+
// The user now knows which package failed and what packages remain to be published
44794479
p.cargo("publish --workspace --no-verify")
44804480
.replace_crates_io(registry.index_url())
44814481
.with_status(101)
@@ -4491,6 +4491,10 @@ fn workspace_publish_rate_limit_error() {
44914491
[UPLOADING] package_a v0.1.0 ([ROOT]/foo/package_a)
44924492
[ERROR] failed to publish package_a v0.1.0 to registry at http://127.0.0.1:[..]/
44934493
4494+
[NOTE] the following crates have not been published yet:
4495+
package_b v0.1.0 ([ROOT]/foo/package_b)
4496+
package_c v0.1.0 ([ROOT]/foo/package_c)
4497+
44944498
Caused by:
44954499
failed to get a 200 OK response, got 429
44964500
headers:

0 commit comments

Comments
 (0)