Forge bridge: say each member of a delivery group once: the seat named novox/mesh-sdk#189 twice in feat/47-G-join11, and every repository with a branch of that name was refused its take-in whole
This commit is contained in:
@@ -230,11 +230,21 @@ func Rows(of []seat.Group, published, ended map[string]string, asks map[string][
|
||||
|
||||
func sortRows(rows []Row) { sort.Slice(rows, func(i, j int) bool { return rows[i].Key < rows[j].Key }) }
|
||||
|
||||
// MembersOf are a group's members with their heads, in the group's order.
|
||||
// MembersOf are a group's members with their heads, in the group's order, each pull request once: a group the seat
|
||||
// answers with a member twice (feat/47-G-join11 named novox/mesh-sdk#189 twice, 2026-11-14) keeps the later head at the
|
||||
// first place, since a merged message naming a member twice is refused whole and no merge of that branch is taken in.
|
||||
func MembersOf(g seat.Group) []meshdeliveryclient.Head {
|
||||
out := make([]meshdeliveryclient.Head, 0, len(g.Members))
|
||||
at := map[string]int{}
|
||||
for _, m := range g.Members {
|
||||
out = append(out, meshdeliveryclient.Head{Repository: m.Repository, Number: int(m.Number), Head: m.Head})
|
||||
h := meshdeliveryclient.Head{Repository: m.Repository, Number: int(m.Number), Head: m.Head}
|
||||
k := fmt.Sprintf("%s#%d", m.Repository, m.Number)
|
||||
if i, twice := at[k]; twice {
|
||||
out[i] = h
|
||||
continue
|
||||
}
|
||||
at[k] = len(out)
|
||||
out = append(out, h)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -40,4 +40,10 @@ func TestReadsNeverAskTheEndedGroupsWhole(t *testing.T) {
|
||||
if _, err := ReadAll(context.Background(), seatOf); err == nil {
|
||||
t.Errorf("ReadAll: want the seat's refusal to be an error, never read as no group")
|
||||
}
|
||||
// A member the seat names twice is said once, at its later head (2026-11-14: the take-in of every repository with a
|
||||
// branch of that group was refused whole).
|
||||
twice := seat.Group{ID: "feat/twice", Members: []seat.Member{{Repository: "o/a", Number: 1, Head: "old"}, {Repository: "o/b", Number: 2, Head: "b"}, {Repository: "o/a", Number: 1, Head: "new"}}}
|
||||
if got := MembersOf(twice); len(got) != 2 || got[0].Repository != "o/a" || got[0].Head != "new" || got[1].Repository != "o/b" {
|
||||
t.Errorf("MembersOf a group naming o/a#1 twice = %+v, want o/a#1 at new, then o/b#2", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user