Skip to content

Commit 9e13390

Browse files
committed
fix: config filepath.Abs errors, file-exist check, git error handling, iteragent v1.5.0
1 parent e2ffc42 commit 9e13390

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

cmd/iterate/config.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ func saveConfig(cfg iterConfig) {
120120
tomlPath := configPathTOML()
121121
jsonPath := configPath()
122122

123-
_, tomlExists := os.Stat(tomlPath)
124-
_, jsonExists := os.Stat(jsonPath)
123+
_, tomlErr := os.Stat(tomlPath)
124+
_, jsonErr := os.Stat(jsonPath)
125125

126-
if tomlExists == nil || jsonExists != nil {
126+
if tomlErr == nil || jsonErr != nil {
127127
// Write TOML.
128128
if err := os.MkdirAll(filepath.Dir(tomlPath), 0o755); err != nil {
129129
slog.Warn("failed to create TOML config dir", "err", err)
@@ -226,7 +226,10 @@ func checkDirPermission(cfg iterConfig, filePath string) (denied bool) {
226226
}
227227
// DenyDirs: block if path is under any denied directory.
228228
for _, d := range cfg.DenyDirs {
229-
dAbs, _ := filepath.Abs(d)
229+
dAbs, err := filepath.Abs(d)
230+
if err != nil {
231+
continue
232+
}
230233
rel, err := filepath.Rel(dAbs, abs)
231234
if err == nil && !strings.HasPrefix(rel, "..") {
232235
return true
@@ -235,7 +238,10 @@ func checkDirPermission(cfg iterConfig, filePath string) (denied bool) {
235238
// AllowDirs: if set, path must be under at least one allowed dir.
236239
if len(cfg.AllowDirs) > 0 {
237240
for _, d := range cfg.AllowDirs {
238-
dAbs, _ := filepath.Abs(d)
241+
dAbs, err := filepath.Abs(d)
242+
if err != nil {
243+
continue
244+
}
239245
rel, err := filepath.Rel(dAbs, abs)
240246
if err == nil && !strings.HasPrefix(rel, "..") {
241247
return false

cmd/iterate/features_prompts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ func buildMockPrompt(filePath string) string {
9999
// ---------------------------------------------------------------------------
100100

101101
func buildReviewPrompt(repoPath string) string {
102-
out, _ := exec.Command("git", "-C", repoPath, "diff", "HEAD").Output()
102+
out, err := exec.Command("git", "-C", repoPath, "diff", "HEAD").Output()
103103
diff := strings.TrimSpace(string(out))
104-
if diff == "" {
104+
if diff == "" || err != nil {
105105
out, _ = exec.Command("git", "-C", repoPath, "diff").Output()
106106
diff = strings.TrimSpace(string(out))
107107
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.0
44

55
require (
66
github.com/BurntSushi/toml v1.6.0
7-
github.com/GrayCodeAI/iteragent v1.4.0
7+
github.com/GrayCodeAI/iteragent v1.5.0
88
github.com/google/go-github/v61 v61.0.0
99
golang.org/x/oauth2 v0.36.0
1010
golang.org/x/term v0.41.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk
22
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
33
github.com/GrayCodeAI/iteragent v1.4.0 h1:BSW/Zj0142sXO6vZrC47LUqLt5O3M6eepgpG+VEDMxk=
44
github.com/GrayCodeAI/iteragent v1.4.0/go.mod h1:wsIv7o17FthxfJ1zzbqgPdnVSSlUOxmEC2ch96S+4hY=
5+
github.com/GrayCodeAI/iteragent v1.5.0 h1:Z7weM5U6SOgFBf6AH2clSxPGeXB0URxGXF1kfhqhpG4=
6+
github.com/GrayCodeAI/iteragent v1.5.0/go.mod h1:wsIv7o17FthxfJ1zzbqgPdnVSSlUOxmEC2ch96S+4hY=
57
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
68
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
79
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=

0 commit comments

Comments
 (0)