Persist merge intent so a restart mid-merge-turn doesn't lose it
This commit is contained in:
@@ -248,6 +248,8 @@ CREATE INDEX lead_inputs_owner ON lead_inputs(owner, id);
|
||||
UPDATE users SET focus = json_set(focus, '$.project_id', (SELECT project_id FROM tasks WHERE id = json_extract(users.focus, '$.task_id')))
|
||||
WHERE json_extract(focus, '$.task_id') IS NOT NULL;
|
||||
DELETE FROM lead_inputs WHERE text LIKE 'The human switched the right pane %' OR text = 'The human cleared the right pane.';
|
||||
`}, {"add-task-merging-by", `
|
||||
ALTER TABLE tasks ADD COLUMN merging_by TEXT NOT NULL DEFAULT '';
|
||||
`}}
|
||||
|
||||
type Store struct {
|
||||
@@ -564,6 +566,29 @@ func (s *Store) SetMergeTitle(ctx context.Context, id, title, actor string) erro
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Store) SetMergingBy(ctx context.Context, id, login string) error {
|
||||
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
|
||||
_, err := tx.ExecContext(ctx, `UPDATE tasks SET merging_by = ? WHERE id = ?`, login, id)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Store) TakeMergingBy(ctx context.Context, id string) (string, error) {
|
||||
login := ""
|
||||
err := s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
|
||||
err := tx.QueryRowContext(ctx, `SELECT merging_by FROM tasks WHERE id = ?`, id).Scan(&login)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ErrNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `UPDATE tasks SET merging_by = '' WHERE id = ?`, id)
|
||||
return err
|
||||
})
|
||||
return login, err
|
||||
}
|
||||
|
||||
func (s *Store) MergeTask(ctx context.Context, id, commit, pushed, actor string) (api.Task, error) {
|
||||
return s.closeTask(ctx, id, api.TaskStatusMerged, commit, actor, "task.merged", map[string]any{"id": id, "commit": commit, "pushed": pushed})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user