Skip to content

Commit

Permalink
fix(gh): add alias to amd64 when filtering assets
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 11, 2022
1 parent 050b089 commit 4126cef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Binary file added bat
Binary file not shown.
7 changes: 5 additions & 2 deletions gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (gr GHRelease) GetGHReleases() (*GHReleaseDl, error) {
return nil, fmt.Errorf("no binary release found")
}

// Pick release assets
// Filter or Pick release assets
matchedAssets := filterAssets(filterAssets(releaseAssets, OS), ARCH)
matchedIdx := 0
if len(matchedAssets) != 1 {
Expand All @@ -94,7 +94,10 @@ func (gr GHRelease) GetGHReleases() (*GHReleaseDl, error) {
// Filter assets by match pattern, falling back to the default assets if no match is found
func filterAssets(assets []APIReleaseAsset, match string) (ret []APIReleaseAsset) {
for _, asset := range assets {
if strings.Contains(strings.ToLower(asset.Name), match) {
lowerName := strings.ToLower(asset.Name)
if strings.Contains(lowerName, match) {
ret = append(ret, asset)
} else if match == "amd64" && (strings.Contains(lowerName, "x64") || strings.Contains(lowerName, "x86_64")) {
ret = append(ret, asset)
}
}
Expand Down

0 comments on commit 4126cef

Please sign in to comment.