@@ -270,13 +270,52 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
270
270
DEFAULT_TIMEOUT
271
271
} ;
272
272
if 0 < timeout {
273
+ let source_description = source. source_id ( ) . to_string ( ) ;
274
+ let short_pkg_descriptions = package_list ( to_confirm. iter ( ) . copied ( ) , "or" ) ;
275
+ if plan. is_empty ( ) {
276
+ opts. gctx . shell ( ) . note ( format ! (
277
+ "waiting for {short_pkg_descriptions} to be available at {source_description}.\n \
278
+ You may press ctrl-c to skip waiting; the {crate} should be available shortly.",
279
+ crate = if to_confirm. len( ) == 1 { "crate" } else { "crates" }
280
+ ) ) ?;
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
+ }
289
+
273
290
let timeout = Duration :: from_secs ( timeout) ;
274
- wait_for_any_publish_confirmation (
291
+ let confirmed = wait_for_any_publish_confirmation (
275
292
opts. gctx ,
276
293
source_ids. original ,
277
294
& to_confirm,
278
295
timeout,
279
- ) ?
296
+ ) ?;
297
+ if !confirmed. is_empty ( ) {
298
+ let short_pkg_description = package_list ( confirmed. iter ( ) . copied ( ) , "and" ) ;
299
+ opts. gctx . shell ( ) . status (
300
+ "Published" ,
301
+ format ! ( "{short_pkg_description} at {source_description}" ) ,
302
+ ) ?;
303
+ } else {
304
+ let short_pkg_descriptions = package_list ( to_confirm. iter ( ) . copied ( ) , "or" ) ;
305
+ opts. gctx . shell ( ) . warn ( format ! (
306
+ "timed out waiting for {short_pkg_descriptions} to be available in {source_description}" ,
307
+ ) ) ?;
308
+ opts. gctx . shell ( ) . note ( format ! (
309
+ "the registry may have a backlog that is delaying making the \
310
+ {crate} available. The {crate} should be available soon.",
311
+ crate = if to_confirm. len( ) == 1 {
312
+ "crate"
313
+ } else {
314
+ "crates"
315
+ }
316
+ ) ) ?;
317
+ }
318
+ confirmed
280
319
} else {
281
320
BTreeSet :: new ( )
282
321
}
@@ -317,17 +356,10 @@ fn wait_for_any_publish_confirmation(
317
356
// of independent progress bars can be a little confusing. There is an
318
357
// overall progress bar managed here.
319
358
source. set_quiet ( true ) ;
320
- let source_description = source. source_id ( ) . to_string ( ) ;
321
359
322
360
let now = std:: time:: Instant :: now ( ) ;
323
361
let sleep_time = Duration :: from_secs ( 1 ) ;
324
362
let max = timeout. as_secs ( ) as usize ;
325
- // Short does not include the registry name.
326
- let short_pkg_descriptions = package_list ( pkgs. iter ( ) . copied ( ) , "or" ) ;
327
- gctx. shell ( ) . note ( format ! (
328
- "waiting for {short_pkg_descriptions} to be available at {source_description}.\n \
329
- You may press ctrl-c to skip waiting; the crate should be available shortly."
330
- ) ) ?;
331
363
let mut progress = Progress :: with_style ( "Waiting" , ProgressStyle :: Ratio , gctx) ;
332
364
progress. tick_now ( 0 , max, "" ) ?;
333
365
let available = loop {
@@ -356,30 +388,12 @@ fn wait_for_any_publish_confirmation(
356
388
357
389
let elapsed = now. elapsed ( ) ;
358
390
if timeout < elapsed {
359
- gctx. shell ( ) . warn ( format ! (
360
- "timed out waiting for {short_pkg_descriptions} to be available in {source_description}" ,
361
- ) ) ?;
362
- gctx. shell ( ) . note (
363
- "the registry may have a backlog that is delaying making the \
364
- crate available. The crate should be available soon.",
365
- ) ?;
366
391
break BTreeSet :: new ( ) ;
367
392
}
368
393
369
394
progress. tick_now ( elapsed. as_secs ( ) as usize , max, "" ) ?;
370
395
std:: thread:: sleep ( sleep_time) ;
371
396
} ;
372
- if !available. is_empty ( ) {
373
- let short_pkg_description = available
374
- . iter ( )
375
- . map ( |pkg| format ! ( "{} v{}" , pkg. name( ) , pkg. version( ) ) )
376
- . sorted ( )
377
- . join ( ", " ) ;
378
- gctx. shell ( ) . status (
379
- "Published" ,
380
- format ! ( "{short_pkg_description} at {source_description}" ) ,
381
- ) ?;
382
- }
383
397
384
398
Ok ( available)
385
399
}
@@ -691,6 +705,10 @@ impl PublishPlan {
691
705
self . dependencies_count . is_empty ( )
692
706
}
693
707
708
+ fn len ( & self ) -> usize {
709
+ self . dependencies_count . len ( )
710
+ }
711
+
694
712
/// Returns the set of packages that are ready for publishing (i.e. have no outstanding dependencies).
695
713
///
696
714
/// These will not be returned in future calls.
@@ -727,7 +745,7 @@ impl PublishPlan {
727
745
fn package_list ( pkgs : impl IntoIterator < Item = PackageId > , final_sep : & str ) -> String {
728
746
let mut names: Vec < _ > = pkgs
729
747
. into_iter ( )
730
- . map ( |pkg| format ! ( "` {} v{}` " , pkg. name( ) , pkg. version( ) ) )
748
+ . map ( |pkg| format ! ( "{} v{}" , pkg. name( ) , pkg. version( ) ) )
731
749
. collect ( ) ;
732
750
names. sort ( ) ;
733
751
0 commit comments