@@ -270,13 +270,41 @@ 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
+ opts. gctx . shell ( ) . note ( format ! (
276
+ "waiting for {short_pkg_descriptions} to be available at {source_description}.\n \
277
+ You may press ctrl-c to skip waiting; the crate should be available shortly."
278
+ ) ) ?;
279
+
273
280
let timeout = Duration :: from_secs ( timeout) ;
274
- wait_for_any_publish_confirmation (
281
+ let confirmed = wait_for_any_publish_confirmation (
275
282
opts. gctx ,
276
283
source_ids. original ,
277
284
& to_confirm,
278
285
timeout,
279
- ) ?
286
+ ) ?;
287
+ if !confirmed. is_empty ( ) {
288
+ let short_pkg_description = confirmed
289
+ . iter ( )
290
+ . map ( |pkg| format ! ( "{} v{}" , pkg. name( ) , pkg. version( ) ) )
291
+ . sorted ( )
292
+ . join ( ", " ) ;
293
+ opts. gctx . shell ( ) . status (
294
+ "Published" ,
295
+ format ! ( "{short_pkg_description} at {source_description}" ) ,
296
+ ) ?;
297
+ } else {
298
+ let short_pkg_descriptions = package_list ( to_confirm. iter ( ) . copied ( ) , "or" ) ;
299
+ opts. gctx . shell ( ) . warn ( format ! (
300
+ "timed out waiting for {short_pkg_descriptions} to be available in {source_description}" ,
301
+ ) ) ?;
302
+ opts. gctx . shell ( ) . note (
303
+ "the registry may have a backlog that is delaying making the \
304
+ crate available. The crate should be available soon.",
305
+ ) ?;
306
+ }
307
+ confirmed
280
308
} else {
281
309
BTreeSet :: new ( )
282
310
}
@@ -317,17 +345,10 @@ fn wait_for_any_publish_confirmation(
317
345
// of independent progress bars can be a little confusing. There is an
318
346
// overall progress bar managed here.
319
347
source. set_quiet ( true ) ;
320
- let source_description = source. source_id ( ) . to_string ( ) ;
321
348
322
349
let now = std:: time:: Instant :: now ( ) ;
323
350
let sleep_time = Duration :: from_secs ( 1 ) ;
324
351
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
352
let mut progress = Progress :: with_style ( "Waiting" , ProgressStyle :: Ratio , gctx) ;
332
353
progress. tick_now ( 0 , max, "" ) ?;
333
354
let available = loop {
@@ -356,30 +377,12 @@ fn wait_for_any_publish_confirmation(
356
377
357
378
let elapsed = now. elapsed ( ) ;
358
379
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
380
break BTreeSet :: new ( ) ;
367
381
}
368
382
369
383
progress. tick_now ( elapsed. as_secs ( ) as usize , max, "" ) ?;
370
384
std:: thread:: sleep ( sleep_time) ;
371
385
} ;
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
386
384
387
Ok ( available)
385
388
}
0 commit comments