Commit and snapshot in ask_human before suggesting a main merge

This commit is contained in:
Ian Gulliver
2026-10-20 09:11:19 -07:00
parent 3989c2f156
commit 29c993cde0
10 changed files with 229 additions and 211 deletions
+22 -5
View File
@@ -175,12 +175,29 @@ func (m *Manager) ask(ctx context.Context, l *live, raw json.RawMessage) (string
if err != nil {
slog.Error("count commits behind default branch", "task", task.Id, "err", err)
}
if behind > 0 {
return filed + fmt.Sprintf("This worktree is %d commits behind %s. While the human answers is a good time to merge %s in: "+
"commit your work if the tree isn't clean, run `git merge %s`, resolve any conflicts, and check the result. Then end your turn. ",
behind, project.DefaultBranch, project.DefaultBranch, project.DefaultBranch) + rest, nil
if behind == 0 || m.ownsTask(l.id) {
return filed + "End your turn now. " + rest, nil
}
return filed + "End your turn now. " + rest, nil
err = m.commitBeforeSync(ctx, l, project.DefaultBranch)
if err != nil {
slog.Error("commit before merging default branch", "task", task.Id, "err", err)
m.recordError(l, fmt.Sprintf("byre couldn't commit and snapshot the worktree before suggesting a merge of %s: %v", project.DefaultBranch, err))
return filed + "End your turn now. " + rest, nil
}
return filed + fmt.Sprintf("This worktree is %d commits behind %s, and byre has committed and snapshotted your work so far. While the human answers is a good time to merge %s in: "+
"run `git merge --no-ff --no-commit %s`, resolve any conflicts, check the result, and leave the merge uncommitted; byre's end-of-turn commit concludes it. Then end your turn. ",
behind, project.DefaultBranch, project.DefaultBranch, project.DefaultBranch) + rest, nil
}
func (m *Manager) commitBeforeSync(ctx context.Context, l *live, branch string) error {
unlock := m.lockTask(l.taskID)
defer unlock()
_, err := git.CommitAll(l.dir, "Work before merging "+branch, l.gitName, l.gitEmail)
if err != nil {
return err
}
_, err = m.cutSnapshot(ctx, liveTarget(l), true, api.SnapshotTriggerAskHuman)
return err
}
type cancelArgs struct {