-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(prune): skip remote version resolution for tracked configs #9406
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
Changes from 4 commits
2b27f92
5171a18
8ccea7b
1e335ae
5316331
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,7 @@ impl ToolVersion { | |
| latest_versions: true, | ||
| use_locked_version: false, | ||
| before_date: base_opts.before_date, | ||
| offline: base_opts.offline, | ||
| }; | ||
| let tv = self.request.resolve(config, &opts).await?; | ||
| // map cargo backend specific prefixes to ref | ||
|
|
@@ -339,7 +340,7 @@ impl ToolVersion { | |
| } | ||
|
|
||
| let settings = Settings::get(); | ||
| let is_offline = settings.offline(); | ||
| let is_offline = settings.offline() || opts.offline; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — fixed in 5171a18. This comment was generated by an AI coding assistant. |
||
|
|
||
| if v == "latest" { | ||
| if !opts.latest_versions | ||
|
|
@@ -362,6 +363,13 @@ impl ToolVersion { | |
| return build(v); | ||
| } | ||
| } | ||
| // Prune-style offline (opts.offline) wants a non-erroring no-op | ||
| // when nothing is installed — the literal "latest" can't match | ||
| // any installed pathname so it's safe. Global MISE_OFFLINE keeps | ||
| // the original error to avoid surprising upgrade/outdated callers. | ||
| if opts.offline { | ||
| return build(v); | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| return Err(Self::no_versions_found(&backend, opts.before_date)); | ||
| } | ||
| if !opts.latest_versions { | ||
|
|
@@ -449,6 +457,21 @@ impl ToolVersion { | |
| opts: &ResolveOptions, | ||
| ) -> Result<Self> { | ||
| let backend = request.backend()?; | ||
| if v == "latest" && opts.offline { | ||
| // Use the latest installed version as the basis for the sub | ||
| // computation so the resolved concrete version still matches an | ||
| // installed pathname (and gets protected from prune). Falling | ||
| // straight to the raw "sub-N:latest" string would never match | ||
| // anything in `to_delete`. | ||
| if !opts.latest_versions | ||
| && let Some(latest) = backend.latest_installed_version(None)? | ||
| { | ||
| let v = tool_request::version_sub(&latest, sub); | ||
| return Box::pin(Self::resolve_version(config, request, &v, opts)).await; | ||
| } | ||
| let version = request.version(); | ||
| return Ok(Self::new(request, version)); | ||
| } | ||
|
greptile-apps[bot] marked this conversation as resolved.
cursor[bot] marked this conversation as resolved.
|
||
| let v = match v { | ||
| "latest" => backend | ||
| .latest_version(config, None, opts.before_date) | ||
|
|
@@ -472,6 +495,9 @@ impl ToolVersion { | |
| { | ||
| return Ok(Self::new(request, v.to_string())); | ||
| } | ||
| if opts.offline { | ||
| return Ok(Self::new(request, prefix.to_string())); | ||
| } | ||
| let matches = backend | ||
| .list_versions_matching_with_opts(config, prefix, opts.before_date) | ||
| .await?; | ||
|
|
@@ -553,6 +579,8 @@ pub struct ResolveOptions { | |
| pub use_locked_version: bool, | ||
| /// Only consider versions released before this timestamp | ||
| pub before_date: Option<Timestamp>, | ||
| /// Additive to `Settings::offline()` — either being true skips remote version listing. | ||
| pub offline: bool, | ||
| } | ||
|
|
||
| impl Default for ResolveOptions { | ||
|
|
@@ -561,6 +589,7 @@ impl Default for ResolveOptions { | |
| latest_versions: false, | ||
| use_locked_version: true, | ||
| before_date: None, | ||
| offline: false, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -598,6 +627,9 @@ impl Display for ResolveOptions { | |
| if let Some(ts) = &self.before_date { | ||
| opts.push(format!("before_date={ts}")); | ||
| } | ||
| if self.offline { | ||
| opts.push("offline".to_string()); | ||
| } | ||
| write!(f, "({})", opts.join(", ")) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offline: falseoffline: falseis already the value produced byDefault::default(), so this explicit field is unnecessary ininstall.rs,upgrade.rs, anduse.rs. The pattern is consistent across all three callers, which helps with readability, but ifResolveOptions::default()is ever changed to use a different default, these explicitfalses would mask the inconsistency — consider leaving them as a documentation signal or adding a comment explaining they are intentionally overriding the default.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving as-is — the surrounding initializers in
install.rs,upgrade.rs, anduse.rsalready list every field ofResolveOptionsexplicitly rather than using..Default::default(), so the explicitoffline: falsematches the local style and serves as the documentation signal you mentioned. Happy to revisit ifjdxprefers the spread form.This comment was generated by an AI coding assistant.