-
-
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
[#32] Add tag option to download a specific tool version #61
Conversation
cb9e4f4
to
e3bafd9
Compare
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.
This looks amazing 👏🏻
I have a few suggestions to improve some tests and simplify the code in a few places. But overall it looks great 👍🏻
# uncomment to download a specific version or tag | ||
# tag = "12.1.1" |
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.
Thanks for updating the documentation as well! 👏🏻
src/config/toml.rs
Outdated
@@ -275,6 +281,7 @@ mod tests { | |||
macos: Some("C3-PO".to_owned()), | |||
windows: Some("IG-88".to_owned()), | |||
}, | |||
tag: None, |
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 test single_full_tool
checks all the fields in a single TOML table of a tool. So let's add tag
to the TOML text and expect Some(...)
in this last test
src/sync/configure.rs
Outdated
let tag = config_asset | ||
.tag | ||
.clone() | ||
.map(|version| ToolInfoTag::Specific(version)) |
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'm not sure but I believe this simplification should compile 🤔
.map(|version| ToolInfoTag::Specific(version)) | |
.map(ToolInfoTag::Specific) |
@@ -257,7 +277,8 @@ mod tests { | |||
linux: Some("my-linux".to_string()), | |||
macos: Some("my-macos".to_string()), | |||
windows: Some("yours-windows".to_string()), | |||
} | |||
}, | |||
tag: ToolInfoTag::Specific("3.2.1".to_string()), |
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.
Really appreciate updated tests 🙏🏻
src/sync/download.rs
Outdated
if let Some(tag) = self.specific_tag { | ||
format!( | ||
"https://api.github.com/repos/{owner}/{repo}/releases/tags/{tag}", | ||
owner = self.owner, | ||
repo = self.repo, | ||
tag = tag, | ||
) | ||
} else { | ||
format!( | ||
"https://api.github.com/repos/{owner}/{repo}/releases/latest", | ||
owner = self.owner, | ||
repo = self.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.
I propose a slight simplification to this logic. Let's rename as_specific_tag
to to_str_version
and make this function return String
.
This way, this formatting could be just:
format!(
"https://api.github.com/repos/{owner}/{repo}/releases/{version}",
owner = self.owner,
repo = self.repo,
version = tag.to_str_version(),
)
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.
Awesome, thanks for the contribution! 👍🏻
Description
This should resolve #32 which just adds
tag
option to specify which version of the tool to download. If omitted it will default to the latest release.