Skip to content

Commit c29fb2c

Browse files
author
liv
authored
Merge pull request #624 from axodotdev/feat/homebrew-handling
feat: improve homebrew handling
2 parents 50a9039 + b17c6ab commit c29fb2c

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ include_dir = "0.7.3"
5858
slug = "0.1.4"
5959
oranda-generate-css = { version = "0.4.0-prerelease.1", path = "generate-css" }
6060
inquire = "0.6.2"
61+
url-escape = "0.1.1"
6162

6263
[dev-dependencies]
6364
assert_cmd = "2"

src/data/cargo_dist.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ impl ReleaseArtifacts {
5555
// If there's an install-hint, assume this is something we're telling them to run
5656
//
5757
// Special hack: demote npm-packages, which cargo-dist presents kind of weird
58-
let file = if id.contains("npm-package") {
58+
// Also demote Homebrew packages
59+
let file = if id.contains("npm-package")
60+
|| install_hint.contains("brew install")
61+
{
5962
preference = InstallerPreference::Custom;
6063
None
6164
} else {
@@ -82,6 +85,8 @@ impl ReleaseArtifacts {
8285
"powershell".to_owned()
8386
} else if id.contains("npm-package") {
8487
"npm".to_owned()
88+
} else if id.ends_with(".rb") {
89+
"homebrew".to_owned()
8590
} else {
8691
Utf8PathBuf::from(id).extension().unwrap_or(id).to_owned()
8792
};

src/data/release.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,20 @@ impl Release {
153153
gh_release: &GithubRelease,
154154
repo: &GithubRepo,
155155
) -> Result<Option<DistManifest>> {
156-
let tag = &gh_release.tag_name;
156+
let mut encoded_tag = String::new();
157+
url_escape::encode_component_to_string(&gh_release.tag_name, &mut encoded_tag);
157158
if gh_release.has_dist_manifest() {
158159
let request = octolotl::request::ReleaseAsset::new(
159160
&repo.owner,
160161
&repo.name,
161-
tag,
162+
&encoded_tag,
162163
cargo_dist::MANIFEST_FILENAME,
163164
);
164165
let response = octolotl::Request::send(&request, true)
165166
.await?
166167
.error_for_status()?;
167168

168-
Ok(Self::parse_response(response, tag).await?)
169+
Ok(Self::parse_response(response, &gh_release.tag_name).await?)
169170
} else {
170171
Ok(None)
171172
}

0 commit comments

Comments
 (0)