Skip to content

Commit

Permalink
[#55] Don't require 'exe_name' in the configuration (#104)
Browse files Browse the repository at this point in the history
Resolves #55

### Additional tasks

- [ ] Documentation for changes provided/changed
- [x] Tests added

Co-authored-by: Mohammad Mohammadi <[email protected]>
  • Loading branch information
chshersh and mmohammadi9812 authored Sep 20, 2022
1 parent 89a7be2 commit 377e389
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ available [on GitHub][2].
Adding extra lookup path inside asset. Additionally, added a new error message for the case where multiple assets are found
(by [@MitchellBerend][MitchellBerend])
**#SYNC** **#OUTPUT**
* [#55](https://github.com/chshersh/tool-sync/issues/55):
Make `exe_name` optional in the config and use the value of `repo` by default
(by [@mmohammadi9812][mmohammadi9812], [@chshersh][chshersh])
**#CONFIG**

## [0.1.0] — 2022-08-29 🌇

Expand All @@ -89,6 +93,7 @@ Initial release prepared by [@chshersh][chshersh].
[chshersh]: https://github.com/chshersh
[FrancisMurillo]: https://github.com/FrancisMurillo
[MitchellBerend]: https://github.com/MitchellBerend
[mmohammadi9812]: https://github.com/mmohammadi9812
[zixuanzhang-x]: https://github.com/zixuanzhang-x

<!-- Header links -->
Expand Down
37 changes: 36 additions & 1 deletion src/sync/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_else(|| repo.clone());
let tag = config_asset
.tag
.clone()
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 377e389

Please sign in to comment.