Owe a merge to the record from its branch's first kept merge (hq ADR 0276 review)
This commit is contained in:
@@ -64,15 +64,13 @@ func (i *Inventory) LaterMergesOf(ctx context.Context, repository, branch string
|
|||||||
order by merged_at desc`, repository, branch, after)
|
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
|
// KeptOnBranch says the controller keeps a merge of a repository's branch, and when it heard the branch's first: a merge of a branch it keeps merges of, made since then, is the record's to answer, whatever a
|
||||||
// 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).
|
// module's last look says (novox/hq ADR 0276).
|
||||||
func (i *Inventory) KeptOnBranch(ctx context.Context, repository, branch string) (bool, time.Time, error) {
|
func (i *Inventory) KeptOnBranch(ctx context.Context, repository, branch string) (bool, time.Time, error) {
|
||||||
var first *time.Time
|
var first *time.Time
|
||||||
var kept bool
|
var kept bool
|
||||||
err := i.store.Pool().QueryRow(ctx,
|
err := i.store.Pool().QueryRow(ctx,
|
||||||
`select (select min(heard_at) from batched_merge),
|
`select min(heard_at), count(*) > 0 from batched_merge where repository = lower($1) and branch = $2`,
|
||||||
exists (select 1 from batched_merge where repository = lower($1) and branch = $2)`,
|
|
||||||
repository, branch).Scan(&first, &kept)
|
repository, branch).Scan(&first, &kept)
|
||||||
if err != nil || first == nil {
|
if err != nil || first == nil {
|
||||||
return false, time.Time{}, err
|
return false, time.Time{}, err
|
||||||
|
|||||||
Reference in New Issue
Block a user