@@ -270,13 +270,52 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
270270 DEFAULT_TIMEOUT
271271 } ;
272272 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+
273290 let timeout = Duration :: from_secs ( timeout) ;
274- wait_for_any_publish_confirmation (
291+ let confirmed = wait_for_any_publish_confirmation (
275292 opts. gctx ,
276293 source_ids. original ,
277294 & to_confirm,
278295 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
280319 } else {
281320 BTreeSet :: new ( )
282321 }
@@ -317,17 +356,10 @@ fn wait_for_any_publish_confirmation(
317356 // of independent progress bars can be a little confusing. There is an
318357 // overall progress bar managed here.
319358 source. set_quiet ( true ) ;
320- let source_description = source. source_id ( ) . to_string ( ) ;
321359
322360 let now = std:: time:: Instant :: now ( ) ;
323361 let sleep_time = Duration :: from_secs ( 1 ) ;
324362 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- ) ) ?;
331363 let mut progress = Progress :: with_style ( "Waiting" , ProgressStyle :: Ratio , gctx) ;
332364 progress. tick_now ( 0 , max, "" ) ?;
333365 let available = loop {
@@ -356,30 +388,12 @@ fn wait_for_any_publish_confirmation(
356388
357389 let elapsed = now. elapsed ( ) ;
358390 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- ) ?;
366391 break BTreeSet :: new ( ) ;
367392 }
368393
369394 progress. tick_now ( elapsed. as_secs ( ) as usize , max, "" ) ?;
370395 std:: thread:: sleep ( sleep_time) ;
371396 } ;
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- }
383397
384398 Ok ( available)
385399}
@@ -691,6 +705,10 @@ impl PublishPlan {
691705 self . dependencies_count . is_empty ( )
692706 }
693707
708+ fn len ( & self ) -> usize {
709+ self . dependencies_count . len ( )
710+ }
711+
694712 /// Returns the set of packages that are ready for publishing (i.e. have no outstanding dependencies).
695713 ///
696714 /// These will not be returned in future calls.
@@ -727,7 +745,7 @@ impl PublishPlan {
727745fn package_list ( pkgs : impl IntoIterator < Item = PackageId > , final_sep : & str ) -> String {
728746 let mut names: Vec < _ > = pkgs
729747 . into_iter ( )
730- . map ( |pkg| format ! ( "` {} v{}` " , pkg. name( ) , pkg. version( ) ) )
748+ . map ( |pkg| format ! ( "{} v{}" , pkg. name( ) , pkg. version( ) ) )
731749 . collect ( ) ;
732750 names. sort ( ) ;
733751
0 commit comments