mesh-delivery-checker: let a try asked by a bare commit take a mesh-sdk pin that is the head of a mesh-sdk branch, naming it, as a try asked by branch does (issue 1921, issue 1624, try speed S12)

This commit is contained in:
2026-10-25 02:03:26 +02:00
parent 4169faf3f0
commit 50a2e4c4e2
2 changed files with 33 additions and 5 deletions
@@ -118,8 +118,10 @@ func (st *state) checkPinsOf(ctx context.Context, t *target) verdictPtr {
return nil
}
// sameBranchPin names the branch of the tried repository that points at the tried head and that mesh-sdk also has, at the
// commit the pin names; empty when there is none.
// sameBranchPin names the mesh-sdk branch whose head the pin is, for a try: the branch of the tried repository that points
// at the tried head and that mesh-sdk also has, at the commit the pin names, first; else any branch of mesh-sdk but its
// trunk whose head the pin is, for a try asked by a bare commit that no branch of the tried repository points at (issue
// 1624; try speed S12). Empty when there is none.
func (st *state) sameBranchPin(ctx context.Context, t *target, pin string) (string, error) {
mine, err := st.j.Forge.BranchHeads(ctx, t.pull.Repository)
if err != nil {
@@ -131,9 +133,6 @@ func (st *state) sameBranchPin(ctx context.Context, t *target, pin string) (stri
same = append(same, name)
}
}
if len(same) == 0 {
return "", nil
}
sdk, err := st.j.Forge.BranchHeads(ctx, SDKRepository)
if err != nil {
return "", err
@@ -144,6 +143,16 @@ func (st *state) sameBranchPin(ctx context.Context, t *target, pin string) (stri
return name, nil
}
}
var any []string
for name, h := range sdk {
if name != "main" && strings.HasPrefix(h, pin) {
any = append(any, name)
}
}
sort.Strings(any)
if len(any) > 0 {
return any[0], nil
}
return "", nil
}
@@ -408,3 +408,22 @@ func TestAMergeCheckWithTheSameBranchPinIsStillRefusedWithoutAGroupPullRequest(t
t.Fatalf("verdict = %+v", v)
}
}
// Issue 1624 (met again on 2026-10-25; try speed S12): a try asked by a bare commit, which no branch of the tried
// repository points at, still takes a pin that is the head of a mesh-sdk branch, naming that branch; a pin that is the head
// of no mesh-sdk branch is still refused.
func TestATryByCommitTakesAPinThatIsTheHeadOfAnSDKBranch(t *testing.T) {
b, c := sameBranchBench(t, head2[:12])
b.ex.Forge.(*fakeForge).branches[repoA] = map[string]string{"main": trunkA, "feat/r6": trunkA2} // the branch moved on
if v := b.judge(t, c).Verdict; v.State != delivery.VerdictPass {
t.Fatalf("verdict = %+v", v)
}
if n := c.Notes(); len(n) != 1 || n[0] != "pin accepted: head of mesh-sdk feat/r6" {
t.Errorf("notes = %q", n)
}
b, c = sameBranchBench(t, "9aaa5c80ac5c")
b.ex.Forge.(*fakeForge).branches[repoA] = map[string]string{"main": trunkA}
if v := b.judge(t, c).Verdict; v.State != delivery.VerdictFail || !strings.Contains(v.Failed.Words, "neither on mesh-sdk's trunk") {
t.Errorf("a pin no mesh-sdk branch holds: verdict = %+v", v)
}
}