Skip to content

Commit a814076

Browse files
committed
Add more information to wait-for-publish
1 parent 5eef715 commit a814076

File tree

9 files changed

+178
-75
lines changed

9 files changed

+178
-75
lines changed

crates/cargo-test-support/src/compare.rs

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ fn substitute_macros(input: &str) -> String {
231231
("[EXECUTABLE]", " Executable"),
232232
("[SKIPPING]", " Skipping"),
233233
("[WAITING]", " Waiting"),
234+
("[PUBLISHED]", " Published"),
234235
];
235236
let mut result = input.to_owned();
236237
for &(pat, subst) in &macros {

src/cargo/ops/registry.rs

+33-20
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::util::config::{Config, SslVersionConfig, SslVersionConfigRange};
3636
use crate::util::errors::CargoResult;
3737
use crate::util::important_paths::find_root_manifest_for_wd;
3838
use crate::util::{truncate_with_ellipsis, IntoUrl};
39+
use crate::util::{Progress, ProgressStyle};
3940
use crate::{drop_print, drop_println, version};
4041

4142
/// Registry settings loaded from config files.
@@ -442,13 +443,26 @@ fn wait_for_publish(
442443
) -> CargoResult<()> {
443444
let version_req = format!("={}", pkg.version());
444445
let mut source = SourceConfigMap::empty(config)?.load(registry_src, &HashSet::new())?;
445-
let source_description = source.describe();
446+
// Disable the source's built-in progress bars. Repeatedly showing a bunch
447+
// of independent progress bars can be a little confusing. There is an
448+
// overall progress bar managed here.
449+
source.set_quiet(true);
450+
let source_description = source.source_id().to_string();
446451
let query = Dependency::parse(pkg.name(), Some(&version_req), registry_src)?;
447452

448453
let now = std::time::Instant::now();
449454
let sleep_time = std::time::Duration::from_secs(1);
450-
let mut logged = false;
451-
loop {
455+
let max = timeout.as_secs() as usize;
456+
config.shell().status("Published", pkg.to_string())?;
457+
// Short does not include the registry name.
458+
let short_pkg_description = format!("{} v{}", pkg.name(), pkg.version());
459+
config.shell().note(format!(
460+
"Waiting up to {max} seconds for `{short_pkg_description}` to be available at {source_description}.\n\
461+
You may press ctrl-c to skip waiting; the crate should be available shortly."
462+
))?;
463+
let mut progress = Progress::with_style("Waiting", ProgressStyle::Ratio, config);
464+
progress.tick_now(0, max, "")?;
465+
let is_available = loop {
452466
{
453467
let _lock = config.acquire_package_cache_lock()?;
454468
// Force re-fetching the source
@@ -470,31 +484,30 @@ fn wait_for_publish(
470484
}
471485
};
472486
if !summaries.is_empty() {
473-
break;
487+
break true;
474488
}
475489
}
476490

477-
if timeout < now.elapsed() {
491+
let elapsed = now.elapsed();
492+
if timeout < elapsed {
478493
config.shell().warn(format!(
479-
"timed out waiting for `{}` to be in {}",
480-
pkg.name(),
481-
source_description
494+
"timed out waiting for `{short_pkg_description}` to be available in {source_description}",
482495
))?;
483-
break;
484-
}
485-
486-
if !logged {
487-
config.shell().status(
488-
"Waiting",
489-
format!(
490-
"on `{}` to propagate to {} (ctrl-c to wait asynchronously)",
491-
pkg.name(),
492-
source_description
493-
),
496+
config.shell().note(
497+
"The registry may have a backlog that is delaying making the \
498+
crate available. The crate should be available soon.",
494499
)?;
495-
logged = true;
500+
break false;
496501
}
502+
503+
progress.tick_now(elapsed.as_secs() as usize, max, "")?;
497504
std::thread::sleep(sleep_time);
505+
};
506+
if is_available {
507+
config.shell().status(
508+
"Completed",
509+
format!("{pkg} has been successfully published to {source_description}"),
510+
)?;
498511
}
499512

500513
Ok(())

tests/testsuite/artifact_dep.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,10 @@ fn publish_artifact_dep() {
19211921
[PACKAGING] foo v0.1.0 [..]
19221922
[PACKAGED] [..]
19231923
[UPLOADING] foo v0.1.0 [..]
1924-
[UPDATING] [..]
1924+
[PUBLISHED] foo v0.1.0 [..]
1925+
note: Waiting [..]
1926+
You may press ctrl-c [..]
1927+
[COMPLETED] foo v0.1.0 [..]
19251928
",
19261929
)
19271930
.run();

tests/testsuite/credential_process.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ Only one of these values may be set, remove one or the other to proceed.
138138
[PACKAGING] foo v0.1.0 [..]
139139
[PACKAGED] [..]
140140
[UPLOADING] foo v0.1.0 [..]
141-
[UPDATING] [..]
141+
[PUBLISHED] foo v0.1.0 [..]
142+
note: Waiting [..]
143+
You may press ctrl-c [..]
144+
[COMPLETED] foo v0.1.0 [..]
142145
",
143146
)
144147
.run();
@@ -230,7 +233,10 @@ fn publish() {
230233
[PACKAGING] foo v0.1.0 [..]
231234
[PACKAGED] [..]
232235
[UPLOADING] foo v0.1.0 [..]
233-
[UPDATING] [..]
236+
[PUBLISHED] foo v0.1.0 [..]
237+
note: Waiting [..]
238+
You may press ctrl-c [..]
239+
[COMPLETED] foo v0.1.0 [..]
234240
",
235241
)
236242
.run();

tests/testsuite/cross_publish.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ fn publish_with_target() {
112112
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
113113
[PACKAGED] [..]
114114
[UPLOADING] foo v0.0.0 ([CWD])
115-
[UPDATING] crates.io index
115+
[PUBLISHED] foo v0.0.0 ([CWD])
116+
note: Waiting [..]
117+
You may press ctrl-c [..]
118+
[COMPLETED] foo v0.0.0 [..]
116119
",
117120
)
118121
.run();

tests/testsuite/features_namespaced.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,10 @@ fn publish_no_implicit() {
904904
[PACKAGING] foo v0.1.0 [..]
905905
[PACKAGED] [..]
906906
[UPLOADING] foo v0.1.0 [..]
907-
[UPDATING] [..]
907+
[PUBLISHED] foo v0.1.0 [..]
908+
note: Waiting [..]
909+
You may press ctrl-c [..]
910+
[COMPLETED] foo v0.1.0 [..]
908911
",
909912
)
910913
.run();
@@ -1032,7 +1035,10 @@ fn publish() {
10321035
[FINISHED] [..]
10331036
[PACKAGED] [..]
10341037
[UPLOADING] foo v0.1.0 [..]
1035-
[UPDATING] [..]
1038+
[PUBLISHED] foo v0.1.0 [..]
1039+
note: Waiting [..]
1040+
You may press ctrl-c [..]
1041+
[COMPLETED] foo v0.1.0 [..]
10361042
",
10371043
)
10381044
.run();

0 commit comments

Comments
 (0)