fix: log warnings instead of swallowing errors
- GetAllFilesInPath: log.Printf when file fetch or dir recursion fails - integration_test: use strings.SplitN for owner/repo parsing (idiomatic) Addresses GPT review findings #1, #2.
This commit is contained in:
+3
-1
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -224,7 +225,8 @@ func (c *Client) GetAllFilesInPath(ctx context.Context, owner, repo, path string
|
|||||||
case "file":
|
case "file":
|
||||||
content, err := c.GetFileContent(ctx, owner, repo, entry.Path)
|
content, err := c.GetFileContent(ctx, owner, repo, entry.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue // Skip files we can't read
|
log.Printf("Warning: could not fetch file %s: %v", entry.Path, err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
results[entry.Path] = content
|
results[entry.Path] = content
|
||||||
case "dir":
|
case "dir":
|
||||||
|
|||||||
+5
-7
@@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gitea.weiker.me/rodin/review-bot/gitea"
|
"gitea.weiker.me/rodin/review-bot/gitea"
|
||||||
@@ -43,14 +44,11 @@ func TestIntegration_FullReviewFlow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse owner/repo
|
// Parse owner/repo
|
||||||
owner, repoName := "", ""
|
parts := strings.SplitN(giteaRepo, "/", 2)
|
||||||
for i, c := range giteaRepo {
|
if len(parts) != 2 {
|
||||||
if c == '/' {
|
t.Fatalf("Invalid repo format %q", giteaRepo)
|
||||||
owner = giteaRepo[:i]
|
|
||||||
repoName = giteaRepo[i+1:]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
owner, repoName := parts[0], parts[1]
|
||||||
if owner == "" || repoName == "" {
|
if owner == "" || repoName == "" {
|
||||||
t.Fatalf("Invalid repo format %q", giteaRepo)
|
t.Fatalf("Invalid repo format %q", giteaRepo)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user