Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cargo-update): --precise to allow yanked versions #13333

Merged
merged 7 commits into from
Jan 29, 2024
Next Next commit
refactor(registry): merge called flags into one
  • Loading branch information
weihanglo committed Jan 21, 2024
commit 70e7868ddbe78a56e6dcc4201c4abdffc7304045
14 changes: 8 additions & 6 deletions src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,20 +751,24 @@ impl<'cfg> Source for RegistrySource<'cfg> {
req.update_precise(&requested);
}

let mut called = false;
let callback = &mut |s| {
called = true;
f(s);
};

// If this is a locked dependency, then it came from a lock file and in
// theory the registry is known to contain this version. If, however, we
// come back with no summaries, then our registry may need to be
// updated, so we fall back to performing a lazy update.
if kind == QueryKind::Exact && req.is_locked() && !self.ops.is_updated() {
debug!("attempting query without update");
let mut called = false;
ready!(self
.index
.query_inner(dep.package_name(), &req, &mut *self.ops, &mut |s| {
if dep.matches(s.as_summary()) {
// We are looking for a package from a lock file so we do not care about yank
called = true;
f(s);
callback(s)
}
},))?;
if called {
Expand All @@ -775,7 +779,6 @@ impl<'cfg> Source for RegistrySource<'cfg> {
Poll::Pending
}
} else {
let mut called = false;
ready!(self
.index
.query_inner(dep.package_name(), &req, &mut *self.ops, &mut |s| {
Expand All @@ -789,8 +792,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {
if matched
&& (!s.is_yanked() || self.yanked_whitelist.contains(&s.package_id()))
{
f(s);
called = true;
callback(s);
}
}))?;
if called {
Expand Down