From e3954992af63440986bd39cce889e9c62e1a6b92 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 24 Mar 2026 21:35:12 +0000 Subject: feat: clone story branch in ContainerRunner (ADR-007) - Add BranchName field to task.Task (populated from story at execution time) - Add GetStory to executor Store interface; resolve BranchName from story in both execute() and executeResume() parallel to RepositoryURL resolution - Pass --branch to git clone when BranchName is set; default clone otherwise Co-Authored-By: Claude Sonnet 4.6 --- internal/executor/container.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'internal/executor/container.go') diff --git a/internal/executor/container.go b/internal/executor/container.go index d9ed8ef..d270e20 100644 --- a/internal/executor/container.go +++ b/internal/executor/container.go @@ -101,8 +101,13 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec if err := os.Remove(workspace); err != nil { return fmt.Errorf("removing workspace before clone: %w", err) } - r.Logger.Info("cloning repository", "url", repoURL, "workspace", workspace) - if out, err := r.command(ctx, "git", "clone", repoURL, workspace).CombinedOutput(); err != nil { + r.Logger.Info("cloning repository", "url", repoURL, "workspace", workspace, "branch", t.BranchName) + cloneArgs := []string{"clone"} + if t.BranchName != "" { + cloneArgs = append(cloneArgs, "--branch", t.BranchName) + } + cloneArgs = append(cloneArgs, repoURL, workspace) + if out, err := r.command(ctx, "git", cloneArgs...).CombinedOutput(); err != nil { return fmt.Errorf("git clone failed: %w\n%s", err, string(out)) } if err = os.Chmod(workspace, 0755); err != nil { -- cgit v1.2.3