Skip to content

Commit

Permalink
Update instructions for homebrew when non prefixed tap
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Jul 17, 2024
1 parent c695467 commit 2855407
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changelog

## 0.1.1
## 0.1.2

Initial release
24 changes: 17 additions & 7 deletions src/repositories/homebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,28 @@ impl Repository for Homebrew {

let name = get_name(info);
let tap_org_name = homebrew.repository.split('/').next().unwrap();
let tap_name = homebrew
.repository
.split('/')
.last()
.unwrap()
.trim_start_matches("homebrew-");
let tap_name = homebrew.repository.split('/').last().unwrap();

let contents = if tap_name.starts_with("homebrew-") {
format!(
"$ brew install {tap_org_name}/{}/{name}",
tap_name.trim_start_matches("homebrew-")
)
} else {
vec![
format!(
"$ brew tap {tap_org_name}/{tap_name} https://github.com/{tap_org_name}/{tap_name}"
),
format!("$ brew install {tap_org_name}/{tap_name}/{name}"),
]
.join("\n")
};

Ok(vec![
format!("With [Homebrew](https://brew.sh)"),
format!(""),
format!("```"),
format!("$ brew install {tap_org_name}/{tap_name}/{name}"),
contents,
format!("```"),
])
}
Expand Down

0 comments on commit 2855407

Please sign in to comment.