Skip to content

Commit 778f351

Browse files
committed
refactor(package): Switch to positive logic
1 parent 4a92ad1 commit 778f351

File tree

1 file changed

+5
-5
lines changed
  • src/cargo/ops/cargo_package

1 file changed

+5
-5
lines changed

src/cargo/ops/cargo_package/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ fn do_package<'a>(
243243
// The publish registry doesn't matter unless there are local dependencies,
244244
// so only try to get one if we need it. If they explicitly passed a
245245
// registry on the CLI, we check it no matter what.
246-
let sid = if deps.has_no_dependencies() && opts.reg_or_index.is_none() {
247-
None
248-
} else {
246+
let sid = if deps.has_dependencies() || opts.reg_or_index.is_some() {
249247
let sid = get_registry(ws.gctx(), &just_pkgs, opts.reg_or_index.clone())?;
250248
debug!("packaging for registry {}", sid);
251249
Some(sid)
250+
} else {
251+
None
252252
};
253253
let reg_dir = ws.build_dir().join("package").join("tmp-registry");
254254
sid.map(|sid| TmpRegistry::new(ws.gctx(), reg_dir, sid))
@@ -377,10 +377,10 @@ impl<T: Clone> LocalDependencies<T> {
377377
.collect()
378378
}
379379

380-
pub fn has_no_dependencies(&self) -> bool {
380+
pub fn has_dependencies(&self) -> bool {
381381
self.graph
382382
.iter()
383-
.all(|node| self.graph.edges(node).next().is_none())
383+
.any(|node| self.graph.edges(node).next().is_some())
384384
}
385385
}
386386

0 commit comments

Comments
 (0)