diff --git a/.github/labeler.yml b/.github/labeler.yml index f8fc354..d3eb041 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,24 +1,40 @@ catalog: - - internal/config/data/packages.yaml + - changed-files: + - any-glob-to-any-file: + - internal/config/data/packages.yaml brew: - - internal/brew/** + - changed-files: + - any-glob-to-any-file: + - internal/brew/** installer: - - internal/installer/** + - changed-files: + - any-glob-to-any-file: + - internal/installer/** ci: - - .github/workflows/** + - changed-files: + - any-glob-to-any-file: + - .github/workflows/** docs: - - "*.md" - - docs/** + - changed-files: + - any-glob-to-any-file: + - "*.md" + - docs/** tests: - - "**/*_test.go" + - changed-files: + - any-glob-to-any-file: + - "**/*_test.go" snapshot: - - internal/snapshot/** + - changed-files: + - any-glob-to-any-file: + - internal/snapshot/** ui: - - internal/ui/** + - changed-files: + - any-glob-to-any-file: + - internal/ui/** diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24bf00b..8c23e68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: with: go-version-file: "go.mod" - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: version: v2.11.4 diff --git a/.golangci.yml b/.golangci.yml index df49b3f..ef86cb7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,9 +2,6 @@ version: "2" run: timeout: 5m - exclude-dirs: - - vendor - - testutil formatters: enable: @@ -46,13 +43,11 @@ linters: excludes: - G304 # File path provided as taint input — acceptable for CLI tools exclusions: + paths: + - vendor + - testutil rules: - path: "_test\\.go" linters: - errcheck - gosec - - path: "testutil/" - linters: - - gosec - - errcheck - - unused diff --git a/internal/brew/brew.go b/internal/brew/brew.go index 460bb42..cf2da8a 100644 --- a/internal/brew/brew.go +++ b/internal/brew/brew.go @@ -289,7 +289,9 @@ func CheckDiskSpace() (float64, error) { if err := syscall.Statfs(home, &stat); err != nil { return 0, err } - availableGB := float64(stat.Bavail*uint64(stat.Bsize)) / (1024 * 1024 * 1024) + // stat.Bsize is uint32 on darwin and int64 on linux; the kernel always + // reports a non-negative block size so the conversion is safe. + availableGB := float64(stat.Bavail*uint64(stat.Bsize)) / (1024 * 1024 * 1024) //nolint:gosec // see comment above return availableGB, nil } diff --git a/internal/dotfiles/dotfiles.go b/internal/dotfiles/dotfiles.go index 519a251..38a17de 100644 --- a/internal/dotfiles/dotfiles.go +++ b/internal/dotfiles/dotfiles.go @@ -159,6 +159,19 @@ func resolveBranch(dotfilesPath string) string { branch = strings.TrimPrefix(ref, "refs/remotes/origin/") } } + // origin/HEAD may not be configured locally — ask the remote what its default branch is. + if branch == "" || branch == "HEAD" { + if out, err := gitOutputFunc([]string{"-C", dotfilesPath, "ls-remote", "--symref", "origin", "HEAD"}); err == nil { + for _, line := range strings.Split(string(out), "\n") { + if rest, ok := strings.CutPrefix(line, "ref: "); ok { + if fields := strings.Fields(rest); len(fields) >= 1 { + branch = strings.TrimPrefix(fields[0], "refs/heads/") + break + } + } + } + } + } if branch == "" || branch == "HEAD" { return "main" } diff --git a/internal/snapshot/capture.go b/internal/snapshot/capture.go index e65f251..51c5987 100644 --- a/internal/snapshot/capture.go +++ b/internal/snapshot/capture.go @@ -183,7 +183,7 @@ func CaptureNpm() ([]string, error) { if len(lines) <= 1 { return []string{}, nil } - var packages []string + packages := []string{} for _, line := range lines[1:] { line = strings.TrimSpace(line) if line == "" {