summaryrefslogtreecommitdiff
path: root/internal/executor/container.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/container.go')
-rw-r--r--internal/executor/container.go9
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 {