diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-26 08:28:02 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-26 08:28:02 +0000 |
| commit | 6dcd26901b862aa680a1cb501f24183bcf854abc (patch) | |
| tree | 9fa672be79289b3a4388716fecc355f7a333dc10 /internal | |
| parent | 8bb9ac1328fc4f6b8d8e7aae0d6ea706e502c245 (diff) | |
fix: auto-create story branch if missing at clone time
If git checkout of the story branch fails (branch never pushed to bare
repo), create it from HEAD and push to origin instead of hard-failing
the task.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/executor/container.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/executor/container.go b/internal/executor/container.go index 95717b4..d90a273 100644 --- a/internal/executor/container.go +++ b/internal/executor/container.go @@ -133,7 +133,14 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec if storyBranch != "" { r.Logger.Info("checking out story branch", "branch", storyBranch) if out, err := r.command(ctx, "git", "-C", workspace, "checkout", storyBranch).CombinedOutput(); err != nil { - return fmt.Errorf("git checkout story branch %q failed: %w\n%s", storyBranch, err, string(out)) + // Branch doesn't exist in the remote yet — create it from HEAD and push. + r.Logger.Warn("story branch not found, creating from HEAD", "branch", storyBranch) + if out2, err2 := r.command(ctx, "git", "-C", workspace, "checkout", "-b", storyBranch).CombinedOutput(); err2 != nil { + return fmt.Errorf("git checkout story branch %q failed: %w\n%s\ncreate attempt: %s", storyBranch, err, string(out), string(out2)) + } + if out2, err2 := r.command(ctx, "git", "-C", workspace, "push", "origin", storyBranch).CombinedOutput(); err2 != nil { + r.Logger.Warn("push of auto-created story branch failed", "branch", storyBranch, "error", err2, "output", string(out2)) + } } } if err = os.Chmod(workspace, 0755); err != nil { |
