Keep a merge a cut made history, and build a batch's walk at the branch (hq ADR 0276 review)
This commit is contained in:
@@ -64,6 +64,22 @@ func (i *Inventory) LaterMergesOf(ctx context.Context, repository, branch string
|
||||
order by merged_at desc`, repository, branch, after)
|
||||
}
|
||||
|
||||
// KeptOnBranch says the controller keeps a merge of a repository's branch, and when it heard its first merge
|
||||
// of any: a merge of a branch it keeps merges of, made since then, is the record's to answer, whatever a
|
||||
// module's last look says (novox/hq ADR 0276).
|
||||
func (i *Inventory) KeptOnBranch(ctx context.Context, repository, branch string) (bool, time.Time, error) {
|
||||
var first *time.Time
|
||||
var kept bool
|
||||
err := i.store.Pool().QueryRow(ctx,
|
||||
`select (select min(heard_at) from batched_merge),
|
||||
exists (select 1 from batched_merge where repository = lower($1) and branch = $2)`,
|
||||
repository, branch).Scan(&first, &kept)
|
||||
if err != nil || first == nil {
|
||||
return false, time.Time{}, err
|
||||
}
|
||||
return kept, first.UTC(), nil
|
||||
}
|
||||
|
||||
// AloneMerges is every merge waiting to be walked on its own commit, the newest first (ADR 0276 decision 3).
|
||||
func (i *Inventory) AloneMerges(ctx context.Context) ([]BatchedMerge, error) {
|
||||
return i.merges(ctx, `where plan_id is null and alone order by merged_at desc nulls last, heard_at desc`)
|
||||
|
||||
@@ -152,6 +152,9 @@ type PlanDelivery struct {
|
||||
TakenOverBy string `json:"taken_over_by,omitempty"`
|
||||
// Batch is the window of a batch; nil once it is cut into a walk.
|
||||
Batch *PlanBatch `json:"batch,omitempty"`
|
||||
// Alone says the walk walks one merge on its own commit, after a failed walk carried it in a later one:
|
||||
// built at that commit, not at the branch.
|
||||
Alone bool `json:"alone,omitempty"`
|
||||
}
|
||||
|
||||
// Waiting is whether the walk waits for its delivery's word.
|
||||
|
||||
Reference in New Issue
Block a user