-
-
Notifications
You must be signed in to change notification settings - Fork 948
fix(ubi): show relevent error messages for v-prefixed tags #6183
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 all commits
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| use crate::backend::backend_type::BackendType; | ||
| use crate::backend::static_helpers::try_with_v_prefix; | ||
| use crate::cli::args::BackendArg; | ||
| use crate::config::{Config, Settings}; | ||
| use crate::env::{ | ||
|
|
@@ -108,57 +109,33 @@ impl Backend for UbiBackend { | |
| ctx: &InstallContext, | ||
| mut tv: ToolVersion, | ||
| ) -> eyre::Result<ToolVersion> { | ||
| let mut v = tv.version.to_string(); | ||
| let v = tv.version.to_string(); | ||
| let opts = tv.request.options(); | ||
| let forge = match opts.get("provider") { | ||
| Some(forge) => ForgeType::from_str(forge)?, | ||
| None => ForgeType::default(), | ||
| }; | ||
| let api_url = match opts.get("api_url") { | ||
| Some(api_url) => api_url.strip_suffix("/").unwrap_or(api_url), | ||
| None => match forge { | ||
| ForgeType::GitHub => github::API_URL, | ||
| ForgeType::GitLab => gitlab::API_URL, | ||
| }, | ||
| }; | ||
| let bin_path = opts | ||
| .get("bin_path") | ||
| .cloned() | ||
| .unwrap_or_else(|| "bin".to_string()); | ||
| let extract_all = opts.get("extract_all").is_some_and(|v| v == "true"); | ||
| let bin_dir = tv.install_path(); | ||
|
|
||
| if !name_is_url(&self.tool_name()) { | ||
| let release: Result<_, eyre::Report> = match forge { | ||
| ForgeType::GitHub => github::get_release_for_url(api_url, &self.tool_name(), &v) | ||
| .await | ||
| .map(|_| "github"), | ||
| ForgeType::GitLab => gitlab::get_release_for_url(api_url, &self.tool_name(), &v) | ||
| if name_is_url(&self.tool_name()) { | ||
| install(&self.tool_name(), &v, &bin_dir, extract_all, &opts).await?; | ||
| } else { | ||
| try_with_v_prefix(&v, None, |candidate| { | ||
| let opts = opts.clone(); | ||
| let bin_dir = bin_dir.clone(); | ||
| async move { | ||
| install( | ||
| &self.tool_name(), | ||
| &candidate, | ||
| &bin_dir, | ||
| extract_all, | ||
| &opts, | ||
| ) | ||
| .await | ||
| .map(|_| "gitlab"), | ||
| }; | ||
| if let Err(err) = release { | ||
| // this can fail with a rate limit error or 404, either way, try prefixing and if it fails, try without the prefix | ||
| // if http::error_code(&err) == Some(404) { | ||
| debug!( | ||
| "Failed to get release for {}, trying with 'v' prefix: {}", | ||
| tv, err | ||
| ); | ||
| v = format!("v{v}"); | ||
| // } | ||
| } | ||
| } | ||
|
|
||
| if let Err(err) = install(&self.tool_name(), &v, &bin_dir, extract_all, &opts).await { | ||
| debug!( | ||
| "Failed to install with ubi version '{}': {}, trying with '{}'", | ||
| v, err, tv | ||
| ); | ||
| if let Err(err) = | ||
| install(&self.tool_name(), &tv.version, &bin_dir, extract_all, &opts).await | ||
| { | ||
| bail!("Failed to install with ubi '{}': {}", tv, err); | ||
| } | ||
| } | ||
| }) | ||
| .await?; | ||
|
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. Bug: UBI Backend Ignores Custom Version PrefixThe UBI backend's
Contributor
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. I think this was as is, |
||
| } | ||
|
|
||
| let mut possible_exes = vec![ | ||
|
|
||
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.
The error message should use 'version' directly instead of string interpolation syntax since this is in a closure context where version is captured.