fix(lint): resolve all golangci-lint errors
- Mark unused ctx parameter with underscore in getRepoRootForWorktree
- Replace exec.Command("test", "-d") with os.Stat for directory check
- Handle file.Close() errors properly in compact.go and migrate_tombstones.go
- Explicitly ignore cleanup errors with _ assignment
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1019,7 +1019,9 @@ func pruneExpiredTombstones() (*TombstonePruneResult, error) {
|
|||||||
}
|
}
|
||||||
allIssues = append(allIssues, &issue)
|
allIssues = append(allIssues, &issue)
|
||||||
}
|
}
|
||||||
file.Close()
|
if err := file.Close(); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to close issues file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Determine TTL
|
// Determine TTL
|
||||||
ttl := types.DefaultTombstoneTTL
|
ttl := types.DefaultTombstoneTTL
|
||||||
@@ -1052,20 +1054,20 @@ func pruneExpiredTombstones() (*TombstonePruneResult, error) {
|
|||||||
encoder := json.NewEncoder(tempFile)
|
encoder := json.NewEncoder(tempFile)
|
||||||
for _, issue := range kept {
|
for _, issue := range kept {
|
||||||
if err := encoder.Encode(issue); err != nil {
|
if err := encoder.Encode(issue); err != nil {
|
||||||
tempFile.Close()
|
_ = tempFile.Close()
|
||||||
os.Remove(tempPath)
|
_ = os.Remove(tempPath)
|
||||||
return nil, fmt.Errorf("failed to write issue %s: %w", issue.ID, err)
|
return nil, fmt.Errorf("failed to write issue %s: %w", issue.ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tempFile.Close(); err != nil {
|
if err := tempFile.Close(); err != nil {
|
||||||
os.Remove(tempPath)
|
_ = os.Remove(tempPath)
|
||||||
return nil, fmt.Errorf("failed to close temp file: %w", err)
|
return nil, fmt.Errorf("failed to close temp file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atomically replace
|
// Atomically replace
|
||||||
if err := os.Rename(tempPath, issuesPath); err != nil {
|
if err := os.Rename(tempPath, issuesPath); err != nil {
|
||||||
os.Remove(tempPath)
|
_ = os.Remove(tempPath)
|
||||||
return nil, fmt.Errorf("failed to replace issues.jsonl: %w", err)
|
return nil, fmt.Errorf("failed to replace issues.jsonl: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ Examples:
|
|||||||
existingTombstones[issue.ID] = true
|
existingTombstones[issue.ID] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.Close()
|
_ = file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine which deletions need migration
|
// Determine which deletions need migration
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ func gitHasChanges(ctx context.Context, filePath string) (bool, error) {
|
|||||||
|
|
||||||
// getRepoRootForWorktree returns the main repository root for running git commands
|
// getRepoRootForWorktree returns the main repository root for running git commands
|
||||||
// This is always the main repository root, never the worktree root
|
// This is always the main repository root, never the worktree root
|
||||||
func getRepoRootForWorktree(ctx context.Context) string {
|
func getRepoRootForWorktree(_ context.Context) string {
|
||||||
repoRoot, err := git.GetMainRepoRoot()
|
repoRoot, err := git.GetMainRepoRoot()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Fallback to current directory if GetMainRepoRoot fails
|
// Fallback to current directory if GetMainRepoRoot fails
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package git
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -106,7 +107,7 @@ func GetMainRepoRoot() (string, error) {
|
|||||||
commonDir := getGitDirNoError("--git-common-dir")
|
commonDir := getGitDirNoError("--git-common-dir")
|
||||||
if commonDir != "" {
|
if commonDir != "" {
|
||||||
// Validate that commonDir exists
|
// Validate that commonDir exists
|
||||||
if _, err := exec.Command("test", "-d", commonDir).Output(); err == nil {
|
if info, err := os.Stat(commonDir); err == nil && info.IsDir() {
|
||||||
return filepath.Dir(commonDir), nil
|
return filepath.Dir(commonDir), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user