summaryrefslogtreecommitdiff
path: root/internal/executor/claude.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-16 19:46:44 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-16 19:46:44 +0000
commit17a36cc83980d278a8cab5132bf14de731b352ca (patch)
tree3eceb94fd0467492668692b1a0e4f840a941c9cf /internal/executor/claude.go
parentc2aa026f6ce1c9e216b99d74f294fc133d5fcddd (diff)
fix: repair test regressions and add pre-commit/pre-push verification gates
Fix four pre-existing bugs exposed after resolving a build failure: - sandboxCloneSource: accept any URL scheme for origin remote (was filtering out https://) - setupSandbox callers: fix := shadow variable so sandboxDir is set on BlockedError - parseGeminiStream: parse result lines to return execution errors and cost - TestElaborateTask_InvalidJSONFromClaude: stub Gemini fallback so test is hermetic Add verification infrastructure: - scripts/verify: runs go build + go test -race, used by hooks and deploy - scripts/hooks/pre-commit: blocks commits that don't compile - scripts/hooks/pre-push: blocks pushes where tests fail - scripts/install-hooks: symlinks version-controlled hooks into .git/hooks/ - scripts/deploy: runs scripts/verify before building the binary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/claude.go')
-rw-r--r--internal/executor/claude.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/executor/claude.go b/internal/executor/claude.go
index 7e79ce0..df81f76 100644
--- a/internal/executor/claude.go
+++ b/internal/executor/claude.go
@@ -116,7 +116,7 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi
e.SandboxDir = ""
if projectDir != "" {
var err error
- sandboxDir, err := setupSandbox(t.Agent.ProjectDir, r.Logger)
+ sandboxDir, err = setupSandbox(t.Agent.ProjectDir, r.Logger)
if err != nil {
return fmt.Errorf("setting up sandbox: %w", err)
}
@@ -128,7 +128,7 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi
}
} else if projectDir != "" {
var err error
- sandboxDir, err := setupSandbox(t.Agent.ProjectDir, r.Logger)
+ sandboxDir, err = setupSandbox(t.Agent.ProjectDir, r.Logger)
if err != nil {
return fmt.Errorf("setting up sandbox: %w", err)
}
@@ -236,13 +236,17 @@ func gitSafe(args ...string) []string {
// remote named "local" (a local bare repo that accepts pushes cleanly), then
// falls back to "origin", then to the working copy path itself.
func sandboxCloneSource(projectDir string) string {
- for _, remote := range []string{"local", "origin"} {
- out, err := exec.Command("git", gitSafe("-C", projectDir, "remote", "get-url", remote)...).Output()
- if err == nil {
- u := strings.TrimSpace(string(out))
- if u != "" && (strings.HasPrefix(u, "/") || strings.HasPrefix(u, "file://")) {
- return u
- }
+ // Prefer "local" remote, but only if it points to a local path (accepts pushes).
+ if out, err := exec.Command("git", gitSafe("-C", projectDir, "remote", "get-url", "local")...).Output(); err == nil {
+ u := strings.TrimSpace(string(out))
+ if u != "" && (strings.HasPrefix(u, "/") || strings.HasPrefix(u, "file://")) {
+ return u
+ }
+ }
+ // Fall back to "origin" — any URL scheme is acceptable for cloning.
+ if out, err := exec.Command("git", gitSafe("-C", projectDir, "remote", "get-url", "origin")...).Output(); err == nil {
+ if u := strings.TrimSpace(string(out)); u != "" {
+ return u
}
}
return projectDir