-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
[#55] fetch exe_name from api if ommited #76
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 | ||||
---|---|---|---|---|---|---|
|
@@ -31,7 +31,10 @@ pub fn configure_tool(tool_name: &str, config_asset: &ConfigAsset) -> Tool { | |||||
fn full_configure(config_asset: &ConfigAsset) -> Option<ToolInfo> { | ||||||
let owner = config_asset.owner.clone()?; | ||||||
let repo = config_asset.repo.clone()?; | ||||||
let exe_name = config_asset.exe_name.clone()?; | ||||||
let exe_name = config_asset | ||||||
.exe_name | ||||||
.clone() | ||||||
.unwrap_or(config_asset.repo.clone()?); | ||||||
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.
Suggested change
|
||||||
let tag = config_asset | ||||||
.tag | ||||||
.clone() | ||||||
|
@@ -66,7 +69,7 @@ impl ToolInfo { | |||||
exe_name: config_asset | ||||||
.exe_name | ||||||
.clone() | ||||||
.unwrap_or_else(|| self.exe_name.clone()), | ||||||
.unwrap_or(config_asset.repo.clone().unwrap()), | ||||||
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. Hmm, apparently this shouldn't change at all. |
||||||
asset_name: AssetName { | ||||||
linux: config_asset | ||||||
.asset_name | ||||||
|
@@ -219,6 +222,38 @@ mod tests { | |||||
); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn empty_exe_name() { | ||||||
let tool_name = "abcdef"; | ||||||
|
||||||
let config_asset = ConfigAsset { | ||||||
owner: Some(String::from("chshersh")), | ||||||
repo: Some(String::from("tool-sync")), | ||||||
exe_name: None, | ||||||
asset_name: AssetName { | ||||||
linux: Some(String::from("my-linux")), | ||||||
macos: Some(String::from("my-macos")), | ||||||
windows: Some(String::from("yours-windows")), | ||||||
}, | ||||||
tag: Some(String::from("1.0.0")), | ||||||
}; | ||||||
|
||||||
assert_eq!( | ||||||
configure_tool(tool_name, &config_asset), | ||||||
Tool::Known(ToolInfo { | ||||||
owner: "chshersh".to_string(), | ||||||
repo: "tool-sync".to_string(), | ||||||
exe_name: "tool-sync".to_string(), | ||||||
asset_name: AssetName { | ||||||
linux: Some("my-linux".to_string()), | ||||||
macos: Some("my-macos".to_string()), | ||||||
windows: Some("yours-windows".to_string()), | ||||||
}, | ||||||
tag: ToolInfoTag::Specific("1.0.0".to_string()), | ||||||
}) | ||||||
); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn partial_override() { | ||||||
let tool_name = "ripgrep"; | ||||||
|
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.
If this line is just
Can we not let it error and give some type of output to the user to add an
exe_name
to the config?This way there is no need for an extra api call.
Another approach would be looking for the common substring in the asset names. But I am more in favor of letting the error bubble up so the tool does not download something if the user forgets to add an
exe_name
or they mistake the name of the binary with the repo.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.
Here is a small piece of the json returned by the repos/{owner}/repo/release/tags/{tag} endpoint.
The name is always formatted as
{name}-{tag}-{arch}.some.zip.extension
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.
I don't have many examples in my mind where the tool name is different than repo name and needs explicit user handling, so I don't think that benefits the end user.
The only case where I think manual handling would be beneficial, might be where two or more tools have the same name, or at least same repo name, which I think is a very rare case.
Most of repos, especially the big ones, have a nice consistent format, but it's not forced and so, not always done consistently
An example of such would be teeldear where assets' names are in
{name}-{arch}.*
format: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 original issue #55 was about the ability to not specify the
exe_name
field when therepo
field is specified.repo
is a required field (unless the tool is hardcoded intool-sync
, in that case, you don't need to specify anything) so we always know therepo
name. This way, we don't even need to query the GitHub API to get thename
. We can just userepo
from the config.So I propose to move this discussion and the implementation away from the GitHub API-based implementation toward a simpler design 🙂
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.
Oh I didnt know the release binary names aren't generated.