Skip to content

Commit f36cb83

Browse files
ojuschugh1epage
authored andcommitted
fix(publish): Report which package failed to publish
1 parent 688ec9e commit f36cb83

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/cargo/ops/registry/publish.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,14 @@ fn transmit(
641641
return Ok(());
642642
}
643643

644-
let warnings = registry
645-
.publish(&new_crate, tarball)
646-
.with_context(|| format!("failed to publish to registry at {}", registry.host()))?;
644+
let warnings = registry.publish(&new_crate, tarball).with_context(|| {
645+
format!(
646+
"failed to publish {} v{} to registry at {}",
647+
pkg.name(),
648+
pkg.version(),
649+
registry.host()
650+
)
651+
})?;
647652

648653
if !warnings.invalid_categories.is_empty() {
649654
let msg = format!(

tests/testsuite/publish.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ fn api_error_json() {
22602260
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
22612261
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
22622262
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
2263-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
2263+
[ERROR] failed to publish foo v0.0.1 to registry at http://127.0.0.1:[..]/
22642264
22652265
Caused by:
22662266
the remote server responded with an error (status 403 Forbidden): you must be logged in
@@ -2308,7 +2308,7 @@ fn api_error_200() {
23082308
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
23092309
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
23102310
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
2311-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
2311+
[ERROR] failed to publish foo v0.0.1 to registry at http://127.0.0.1:[..]/
23122312
23132313
Caused by:
23142314
the remote server responded with an [ERROR] max upload size is 123
@@ -2356,7 +2356,7 @@ fn api_error_code() {
23562356
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
23572357
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
23582358
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
2359-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
2359+
[ERROR] failed to publish foo v0.0.1 to registry at http://127.0.0.1:[..]/
23602360
23612361
Caused by:
23622362
failed to get a 200 OK response, got 400
@@ -2413,7 +2413,7 @@ fn api_curl_error() {
24132413
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
24142414
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
24152415
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
2416-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
2416+
[ERROR] failed to publish foo v0.0.1 to registry at http://127.0.0.1:[..]/
24172417
24182418
Caused by:
24192419
[52] Server returned nothing (no headers, no data) (Empty reply from server)
@@ -2461,7 +2461,7 @@ fn api_other_error() {
24612461
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
24622462
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
24632463
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
2464-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
2464+
[ERROR] failed to publish foo v0.0.1 to registry at http://127.0.0.1:[..]/
24652465
24662466
Caused by:
24672467
invalid response body from server
@@ -3608,7 +3608,7 @@ fn invalid_token() {
36083608
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
36093609
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
36103610
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
3611-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
3611+
[ERROR] failed to publish foo v0.0.1 to registry at http://127.0.0.1:[..]/
36123612
36133613
Caused by:
36143614
token contains invalid characters.
@@ -4489,7 +4489,7 @@ fn workspace_publish_rate_limit_error() {
44894489
[UPDATING] crates.io index
44904490
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
44914491
[UPLOADING] package_a v0.1.0 ([ROOT]/foo/package_a)
4492-
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
4492+
[ERROR] failed to publish package_a v0.1.0 to registry at http://127.0.0.1:[..]/
44934493
44944494
Caused by:
44954495
failed to get a 200 OK response, got 429

0 commit comments

Comments
 (0)