From a7f7062a9631c56586c90196769ca3b8920ce87b Mon Sep 17 00:00:00 2001 From: k1LoW Date: Fri, 28 Jul 2023 12:22:10 +0900 Subject: [PATCH 1/2] Add --skip-content-type-check option for skipping check of content type of assets. --- cmd/root.go | 1 + gh/gh.go | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 15caa53..5ab0dde 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -119,5 +119,6 @@ func init() { rootCmd.Flags().StringVarP(&sOpt.BinMatch, "bin-match", "", "", "regexp to match bin path in asset") rootCmd.Flags().BoolVarP(&sOpt.Force, "force", "f", false, "enable force setup") rootCmd.Flags().BoolVarP(&opt.Strict, "strict", "", false, "require strict match") + rootCmd.Flags().BoolVarP(&opt.SkipContentTypeCheck, "skip-content-type-check", "", false, "skip check content-type of assets") rootCmd.Flags().BoolVarP(&verbose, "verbose", "", false, "show verbose log") } diff --git a/gh/gh.go b/gh/gh.go index 1d9ed3a..3b687c3 100644 --- a/gh/gh.go +++ b/gh/gh.go @@ -51,11 +51,12 @@ var supportContentType = []string{ const versionLatest = "latest" type AssetOption struct { - Match string - Version string - OS string - Arch string - Strict bool + Match string + Version string + OS string + Arch string + Strict bool + SkipContentTypeCheck bool } func GetReleaseAsset(ctx context.Context, owner, repo string, opt *AssetOption) (*releaseAsset, fs.FS, error) { @@ -133,7 +134,7 @@ func detectAsset(assets []*releaseAsset, opt *AssetOption) (*releaseAsset, error } assetScores := []*assetScore{} for _, a := range assets { - if a.ContentType != "" && !contains(supportContentType, a.ContentType) { + if !opt.SkipContentTypeCheck && a.ContentType != "" && !contains(supportContentType, a.ContentType) { slog.Info("Skip", slog.String("name", a.Name), slog.String("reason", "Unsupported content type"), From 6cbf7aba8c0d30f523e20422fed11ba74cd999f3 Mon Sep 17 00:00:00 2001 From: k1LoW Date: Fri, 28 Jul 2023 12:28:25 +0900 Subject: [PATCH 2/2] Fix --- gh/gh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gh/gh.go b/gh/gh.go index 3b687c3..87afddb 100644 --- a/gh/gh.go +++ b/gh/gh.go @@ -134,7 +134,7 @@ func detectAsset(assets []*releaseAsset, opt *AssetOption) (*releaseAsset, error } assetScores := []*assetScore{} for _, a := range assets { - if !opt.SkipContentTypeCheck && a.ContentType != "" && !contains(supportContentType, a.ContentType) { + if (opt == nil || !opt.SkipContentTypeCheck) && a.ContentType != "" && !contains(supportContentType, a.ContentType) { slog.Info("Skip", slog.String("name", a.Name), slog.String("reason", "Unsupported content type"),