Refuse turns, discard and subtasks while a merge is finalizing
This commit is contained in:
@@ -320,11 +320,7 @@ func (m *Manager) MergeIntoParent(ctx context.Context, task api.Task, user api.U
|
||||
if found && sess.State == api.AgentSessionStateRunning {
|
||||
return api.Task{}, fmt.Errorf("%w: subtask %s's agent is mid-turn; wait for the turn to end or interrupt it", ErrConflict, task.Id)
|
||||
}
|
||||
mergingBy, err := m.store.MergingBy(ctx, task.Id)
|
||||
if err != nil {
|
||||
return api.Task{}, err
|
||||
}
|
||||
if mergingBy != "" || task.MergeQueuedAt != nil {
|
||||
if task.Merging || task.MergeQueuedAt != nil {
|
||||
return api.Task{}, fmt.Errorf("%w: subtask %s is merging into the default branch", ErrConflict, task.Id)
|
||||
}
|
||||
|
||||
@@ -332,7 +328,7 @@ func (m *Manager) MergeIntoParent(ctx context.Context, task api.Task, user api.U
|
||||
switch {
|
||||
case errors.Is(err, store.ErrNotFound):
|
||||
return api.Task{}, fmt.Errorf("%w: subtask %s is closed", ErrConflict, task.Id)
|
||||
case errors.Is(err, store.ErrDiscardPending), errors.Is(err, store.ErrParentMergeRequested):
|
||||
case errors.Is(err, store.ErrDiscardPending), errors.Is(err, store.ErrMerging), errors.Is(err, store.ErrParentMergeRequested):
|
||||
return api.Task{}, fmt.Errorf("%w: subtask %s: %w", ErrConflict, task.Id, err)
|
||||
case err != nil:
|
||||
return api.Task{}, err
|
||||
|
||||
Reference in New Issue
Block a user