Skip to content

Commit

Permalink
Merge 14e42e9 into 8ae65cb
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Feb 12, 2023
2 parents 8ae65cb + 14e42e9 commit 1fb07e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ func init() {
rootCmd.Flags().StringVarP(&opt.Version, "release-version", "V", "", "release version")
rootCmd.Flags().StringVarP(&opt.OS, "os", "O", "", "specify OS of asset")
rootCmd.Flags().StringVarP(&opt.Arch, "arch", "A", "", "specify arch of asset")
rootCmd.Flags().StringVarP(&opt.Match, "match", "", "", "match string for asset")
}
8 changes: 7 additions & 1 deletion gh/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ func GetReleaseAsset(ctx context.Context, owner, repo string, opt *AssetOption)

func detectAsset(assets []*github.ReleaseAsset, opt *AssetOption) (*github.ReleaseAsset, error) {
var (
od, ad *regexp.Regexp
od, ad, om *regexp.Regexp
)
if opt != nil && opt.Match != "" {
om = regexp.MustCompile(opt.Match)
}
if opt != nil && opt.OS != "" {
od = getDictRegexp(opt.OS, osDict)
} else {
Expand All @@ -100,6 +103,9 @@ func detectAsset(assets []*github.ReleaseAsset, opt *AssetOption) (*github.Relea
}
assetScores := []*assetScore{}
for _, a := range assets {
if om != nil && om.MatchString(a.GetName()) {
return a, nil
}
if !contains(supportContentType, a.GetContentType()) {
continue
}
Expand Down

0 comments on commit 1fb07e2

Please sign in to comment.