diff options
Diffstat (limited to 'internal/executor/claude.go')
| -rw-r--r-- | internal/executor/claude.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/internal/executor/claude.go b/internal/executor/claude.go index f8b0ac2..7e79ce0 100644 --- a/internal/executor/claude.go +++ b/internal/executor/claude.go @@ -116,10 +116,11 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi e.SandboxDir = "" if projectDir != "" { var err error - sandboxDir, err = setupSandbox(projectDir) + sandboxDir, err := setupSandbox(t.Agent.ProjectDir, r.Logger) if err != nil { return fmt.Errorf("setting up sandbox: %w", err) } + effectiveWorkingDir = sandboxDir r.Logger.Info("fresh sandbox created for resume", "sandbox", sandboxDir, "project_dir", projectDir) } @@ -127,10 +128,11 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi } } else if projectDir != "" { var err error - sandboxDir, err = setupSandbox(projectDir) + sandboxDir, err := setupSandbox(t.Agent.ProjectDir, r.Logger) if err != nil { return fmt.Errorf("setting up sandbox: %w", err) } + effectiveWorkingDir = sandboxDir r.Logger.Info("sandbox created", "sandbox", sandboxDir, "project_dir", projectDir) } @@ -236,8 +238,11 @@ func gitSafe(args ...string) []string { 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 && len(strings.TrimSpace(string(out))) > 0 { - return strings.TrimSpace(string(out)) + if err == nil { + u := strings.TrimSpace(string(out)) + if u != "" && (strings.HasPrefix(u, "/") || strings.HasPrefix(u, "file://")) { + return u + } } } return projectDir @@ -245,7 +250,7 @@ func sandboxCloneSource(projectDir string) string { // setupSandbox prepares a temporary git clone of projectDir. // If projectDir is not a git repo it is initialised with an initial commit first. -func setupSandbox(projectDir string) (string, error) { +func setupSandbox(projectDir string, logger *slog.Logger) (string, error) { // Ensure projectDir is a git repo; initialise if not. if err := exec.Command("git", gitSafe("-C", projectDir, "rev-parse", "--git-dir")...).Run(); err != nil { cmds := [][]string{ |
