Skip to content

Commit 2e1f971

Browse files
committed
fix(publish): Don't tell people to ctrl-c without knowing consequences
Fixes #15005
1 parent f016160 commit 2e1f971

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/cargo/ops/registry/publish.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,20 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
272272
if 0 < timeout {
273273
let source_description = source.source_id().to_string();
274274
let short_pkg_descriptions = package_list(to_confirm.iter().copied(), "or");
275-
opts.gctx.shell().note(format!(
275+
if plan.is_empty() {
276+
opts.gctx.shell().note(format!(
276277
"waiting for {short_pkg_descriptions} to be available at {source_description}.\n\
277278
You may press ctrl-c to skip waiting; the {crate} should be available shortly.",
278279
crate = if to_confirm.len() == 1 { "crate" } else {"crates"}
279280
))?;
281+
} else {
282+
opts.gctx.shell().note(format!(
283+
"waiting for {short_pkg_descriptions} to be available at {source_description}.\n\
284+
{count} remaining {crate} to be published",
285+
count = plan.len(),
286+
crate = if plan.len() == 1 { "crate" } else {"crates"}
287+
))?;
288+
}
280289

281290
let timeout = Duration::from_secs(timeout);
282291
let confirmed = wait_for_any_publish_confirmation(
@@ -696,6 +705,10 @@ impl PublishPlan {
696705
self.dependencies_count.is_empty()
697706
}
698707

708+
fn len(&self) -> usize {
709+
self.dependencies_count.len()
710+
}
711+
699712
/// Returns the set of packages that are ready for publishing (i.e. have no outstanding dependencies).
700713
///
701714
/// These will not be returned in future calls.

tests/testsuite/publish.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
33883388
[UPLOADING] dep v0.0.1 ([ROOT]/foo/dep)
33893389
[UPLOADED] dep v0.0.1 to registry `crates-io`
33903390
[NOTE] waiting for dep v0.0.1 to be available at registry `crates-io`.
3391-
You may press ctrl-c to skip waiting; the crate should be available shortly.
3391+
2 remaining crates to be published
33923392
[WARNING] timed out waiting for dep v0.0.1 to be available in registry `crates-io`
33933393
[NOTE] the registry may have a backlog that is delaying making the crate available. The crate should be available soon.
33943394
[ERROR] unable to publish main v0.0.1 and other v0.0.1 due to time out while waiting for published dependencies to be available.
@@ -3785,12 +3785,12 @@ fn workspace_with_local_deps_nightly() {
37853785
[UPLOADING] level3 v0.0.1 ([ROOT]/foo/level3)
37863786
[UPLOADED] level3 v0.0.1 to registry `crates-io`
37873787
[NOTE] waiting for level3 v0.0.1 to be available at registry `crates-io`.
3788-
You may press ctrl-c to skip waiting; the crate should be available shortly.
3788+
2 remaining crates to be published
37893789
[PUBLISHED] level3 v0.0.1 at registry `crates-io`
37903790
[UPLOADING] level2 v0.0.1 ([ROOT]/foo/level2)
37913791
[UPLOADED] level2 v0.0.1 to registry `crates-io`
37923792
[NOTE] waiting for level2 v0.0.1 to be available at registry `crates-io`.
3793-
You may press ctrl-c to skip waiting; the crate should be available shortly.
3793+
1 remaining crate to be published
37943794
[PUBLISHED] level2 v0.0.1 at registry `crates-io`
37953795
[UPLOADING] level1 v0.0.1 ([ROOT]/foo/level1)
37963796
[UPLOADED] level1 v0.0.1 to registry `crates-io`
@@ -3890,7 +3890,7 @@ fn workspace_parallel() {
38903890
[UPLOADED] b v0.0.1 to registry `crates-io`
38913891
[UPLOADED] a v0.0.1 to registry `crates-io`
38923892
[NOTE] waiting for a v0.0.1 or b v0.0.1 to be available at registry `crates-io`.
3893-
You may press ctrl-c to skip waiting; the crates should be available shortly.
3893+
1 remaining crate to be published
38943894
[PUBLISHED] a v0.0.1 and b v0.0.1 at registry `crates-io`
38953895
[UPLOADING] c v0.0.1 ([ROOT]/foo/c)
38963896
[UPLOADED] c v0.0.1 to registry `crates-io`

0 commit comments

Comments
 (0)