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

[#32] Add tag option to download a specific tool version #61

Merged
merged 2 commits into from
Sep 3, 2022

Conversation

FrancisMurillo
Copy link
Contributor

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.

[ripgrep]
owner    = "BurntSushi"
repo     = "ripgrep"
exe_name = "rg"
tag      = "12.1.1"

asset_name.linux = "x86_64-unknown-linux-musl.tar.gz"

@chshersh chshersh added enhancement New feature or request config TOML configuration, config-related CLI options labels Sep 3, 2022
Copy link
Owner

@chshersh chshersh left a 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 👍🏻

Comment on lines +125 to +126
# uncomment to download a specific version or tag
# tag = "12.1.1"
Copy link
Owner

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! 👏🏻

@@ -275,6 +281,7 @@ mod tests {
macos: Some("C3-PO".to_owned()),
windows: Some("IG-88".to_owned()),
},
tag: None,
Copy link
Owner

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

let tag = config_asset
.tag
.clone()
.map(|version| ToolInfoTag::Specific(version))
Copy link
Owner

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 🤔

Suggested change
.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()),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate updated tests 🙏🏻

Comment on lines 28 to 41
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,
)
}
Copy link
Owner

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(),
)

Copy link
Owner

@chshersh chshersh left a 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! 👍🏻

@chshersh chshersh merged commit c790adc into chshersh:main Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config TOML configuration, config-related CLI options enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support not only 'latest' releases
2 participants