Merge pull request 'A group's check names every member at its head, also one that publishes no package yet (issue 1921)' (#159) from fix/1921-zero-pins-own-packages into main

This commit was merged in pull request #159.
This commit is contained in:
2026-11-05 23:00:43 +00:00
2 changed files with 32 additions and 0 deletions
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"maps"
"strings"
"git.novox.be/novox/mesh-sdk/go/delivery"
)
@@ -58,6 +59,28 @@ func (st *state) packagesOf(repository string) delivery.PackageVersions {
delete(versions, pkg)
}
}
// A package of a member that no indexer state publishes yet (a repository whose packages are all new) is in no list above,
// and the build would look for it as the trunk's latest version, which does not exist (issue 1921). The member's root
// module path stands for its repository: the build module takes the head of a repository from any package of it.
for _, m := range st.c.Pulls {
if delivery.SameRepository(m.Repository, repository) || len(m.Head) != 40 {
continue
}
name := strings.TrimPrefix(m.Repository, "novox/")
if m.Repository == name {
continue
}
held := false
for pkg := range versions {
if repo, _, ok := delivery.PackageRepository(pkg); ok && repo == m.Repository {
held = true
break
}
}
if !held {
versions[delivery.ForgeModulePrefix+name] = m.Head
}
}
if len(versions) == 0 {
return nil
}
@@ -60,6 +60,15 @@ func TestAGroupMemberIsBuiltAgainstTheSDKMembersHeadWhateverItsGoModNames(t *tes
if got := packagesOfFetch(t, b, "novox/mesh-catalog"); len(got) != 2 || got[SDKModulePath] != trunkS || got[contract] != trunkA {
t.Errorf("a pull request alone is built against %v, want every package at its latest published version", got)
}
// A member that publishes no package yet is still named, by its root module path, at its head (issue 1921).
b = newBench(t)
b.ex.Published = published{}
if v := b.judge(t, caseOf(t, pullOf(repoA, 7, head1), pullOf("novox/mesh-host", 8, head2))).Verdict; v.State != delivery.VerdictPass {
t.Fatalf("an unpublished member: verdict = %+v", v)
}
if got := packagesOfFetch(t, b, repoA); len(got) != 1 || got["git.novox.be/novox/mesh-host"] != head2 {
t.Errorf("the member's packages = %v, want the unpublished member's root at its head %s alone", got, head2)
}
}
type runsAt map[string]string