Skip to content

Commit 132afd3

Browse files
committed
Fix publishing to crates.io with -Z sparse-registry
1 parent c0bbd42 commit 132afd3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/cargo/ops/registry.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,6 @@ fn verify_dependencies(
196196
if super::check_dep_has_version(dep, true)? {
197197
continue;
198198
}
199-
// Allow publishing to crates.io with index.crates.io as a source replacement.
200-
if registry_src.is_default_registry() && dep.source_id().is_default_registry() {
201-
continue;
202-
}
203199
// TomlManifest::prepare_for_publish will rewrite the dependency
204200
// to be just the `version` field.
205201
if dep.source_id() != registry_src {
@@ -535,6 +531,13 @@ fn registry(
535531
None
536532
};
537533
let handle = http_handle(config)?;
534+
// Workaround for the sparse+https://index.crates.io replacement index. Use the non-replaced
535+
// source_id so that the original (github) url is used when publishing a crate.
536+
let sid = if sid.is_default_registry() {
537+
SourceId::crates_io(config)?
538+
} else {
539+
sid
540+
};
538541
Ok((Registry::new_handle(api_host, token, handle), reg_cfg, sid))
539542
}
540543

0 commit comments

Comments
 (0)