diff --git a/modules/mesh-delivery-checker/internal/check/pins.go b/modules/mesh-delivery-checker/internal/check/pins.go index 1de0a6e..83fb809 100644 --- a/modules/mesh-delivery-checker/internal/check/pins.go +++ b/modules/mesh-delivery-checker/internal/check/pins.go @@ -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 } diff --git a/modules/mesh-delivery-checker/internal/check/pins_test.go b/modules/mesh-delivery-checker/internal/check/pins_test.go index 0c4dba0..5ebb992 100644 --- a/modules/mesh-delivery-checker/internal/check/pins_test.go +++ b/modules/mesh-delivery-checker/internal/check/pins_test.go @@ -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) + } +}