From 5f75c68238d5e3895e2adee92a9b1eef4b5071ec Mon Sep 17 00:00:00 2001 From: MrLYC Date: Thu, 12 Sep 2024 01:00:35 +0800 Subject: [PATCH 1/3] fix download search --- .github/workflows/release.yml | 4 ++-- core/manager/download.go | 4 ++-- go.mod | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0db46d..ac72534 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,13 +16,13 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.19.x + go-version: 1.22.x - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest - args: release --rm-dist --timeout 2h + args: release --timeout 2h env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} \ No newline at end of file diff --git a/core/manager/download.go b/core/manager/download.go index 337242f..dc4c448 100644 --- a/core/manager/download.go +++ b/core/manager/download.go @@ -26,7 +26,7 @@ func (m *DownloadManager) SetReplacements(replacements utils.Replacements) { func (m *DownloadManager) search(name, output string) (string, error) { files := utils.NewSortedHeap(1) - nameLength := float64(len(name)) + nameLower := strings.ToLower(name) err := filepath.Walk(output, func(path string, info fs.FileInfo, err error) error { if err != nil { @@ -43,7 +43,7 @@ func (m *DownloadManager) search(name, output string) (string, error) { } file := filepath.Base(path) - if strings.Contains(file, name) { + if strings.Contains(strings.ToLower(file), nameLower) { score += nameLength / float64(len(file)) } diff --git a/go.mod b/go.mod index c038945..896a7e6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mrlyc/cmdr -go 1.19 +go 1.22 require ( github.com/ahmetb/go-linq/v3 v3.2.0 From b00dd6d1a4ad1595730490adb5376e4997a68827 Mon Sep 17 00:00:00 2001 From: MrLYC Date: Thu, 12 Sep 2024 01:03:44 +0800 Subject: [PATCH 2/3] fix ci --- .github/workflows/integration-test.yml | 2 +- .github/workflows/unittest.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index df6322a..6ede2c4 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - go-version: [1.19.x] + go-version: [1.22.x] os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index f4afebe..7adfe9e 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - go-version: [1.19.x] + go-version: [1.22.x] os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: From 0f235452e62808f24f93890f1f418305c4116c40 Mon Sep 17 00:00:00 2001 From: MrLYC Date: Thu, 12 Sep 2024 01:15:12 +0800 Subject: [PATCH 3/3] bug fixes --- core/manager/download.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/manager/download.go b/core/manager/download.go index dc4c448..d066f38 100644 --- a/core/manager/download.go +++ b/core/manager/download.go @@ -27,6 +27,7 @@ func (m *DownloadManager) SetReplacements(replacements utils.Replacements) { func (m *DownloadManager) search(name, output string) (string, error) { files := utils.NewSortedHeap(1) nameLower := strings.ToLower(name) + nameLength := float64(len(nameLower)) err := filepath.Walk(output, func(path string, info fs.FileInfo, err error) error { if err != nil { @@ -39,7 +40,7 @@ func (m *DownloadManager) search(name, output string) (string, error) { score := 0.0 if info.Mode()&0111 != 0 { - score = 0.1 / nameLength // perfer to choose executable file + score = 0.1 / nameLength // prefer to choose executable file } file := filepath.Base(path)