Skip to content

Commit

Permalink
fix(publish): Allow dry-run of a non-bumped workspace
Browse files Browse the repository at this point in the history
Fixes #14789
  • Loading branch information
epage committed Nov 21, 2024
1 parent 650f13d commit e342906
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
16 changes: 4 additions & 12 deletions src/cargo/sources/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,16 @@ impl<'gctx> Source for DependencyConfusionThreatOverlaySource<'gctx> {
};
ready!(self.local.query(&local_dep, kind, &mut local_callback))?;

let mut package_collision = None;
let mut remote_callback = |index: IndexSummary| {
if local_packages.contains(index.as_summary()) {
package_collision = Some(index.as_summary().clone());
tracing::debug!(?local_source, ?remote_source, ?index, "package collision");
} else {
f(index)
}
f(index)
};
ready!(self.remote.query(dep, kind, &mut remote_callback))?;

if let Some(collision) = package_collision {
std::task::Poll::Ready(Err(anyhow::anyhow!(
"found a package in the remote registry and the local overlay: {}@{}",
collision.name(),
collision.version()
)))
} else {
std::task::Poll::Ready(Ok(()))
}
std::task::Poll::Ready(Ok(()))
}

fn invalidate_cache(&mut self) {
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6056,7 +6056,6 @@ fn workspace_with_local_dep_already_published_nightly() {
p.cargo("package -Zpackage-workspace")
.masquerade_as_nightly_cargo(&["package-workspace"])
.replace_crates_io(reg.index_url())
.with_status(101)
.with_stderr_data(
str![[r#"
[PACKAGING] dep v0.1.0 ([ROOT]/foo/dep)
Expand Down
15 changes: 6 additions & 9 deletions tests/testsuite/registry_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn overlay_version_wins() {
}

#[cargo_test]
fn version_collision() {
fn version_precedence() {
let (reg, alt_path) = setup();
let p = project()
.file(
Expand Down Expand Up @@ -161,16 +161,13 @@ fn version_collision() {

p.cargo("check")
.overlay_registry(&reg.index_url(), &alt_path)
.with_status(101)
.with_stderr_data(str![[r#"
[UPDATING] `sparse+http://127.0.0.1:[..]/index/` index
[ERROR] failed to get `baz` as a dependency of package `foo v0.0.1 ([ROOT]/foo)`
Caused by:
failed to query replaced source registry `crates-io`
Caused by:
found a package in the remote registry and the local overlay: [email protected]
[LOCKING] 1 package to latest compatible version
[UNPACKING] baz v0.1.1 (registry `[ROOT]/alternative-registry`)
[CHECKING] baz v0.1.1
[CHECKING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
Expand Down

0 comments on commit e342906

Please sign in to comment.