Design 47 H1: a release re-pins every entry naming its package
A release re-pinned only the entries whose pins already named one of its packages, so an entry whose module did not change and whose pins left the package out was never re-pinned. Every kept entry whose pins or kept requirements name a package of the released module is now re-pinned, of any repository and changed or not; its fingerprint moves with the pin. Builds: design 47 H H-A-204, H-A-165, H-A-167, H-A-201
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package index
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
@@ -30,3 +34,25 @@ func TestAnEntryNamesEveryRequirementPinnedOrWaiting(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 H-A-204, H-A-165: a release re-pins every kept entry naming one of its packages, of any repository and
|
||||
// changed or not, by its pins or by its kept requirements alone: here g, of another repository, holds no pin of mesh-sdk.
|
||||
func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
||||
objects := map[string]string{"modules/b/builds": strings.Repeat("b", 40), "modules/c/client": strings.Repeat("c", 40)}
|
||||
ix, mods, _ := ptpIndexer(t, objects)
|
||||
f := withManifests(mergedMsg("novox/mesh-delivery", map[string]string{"modules/g": "gtree"}), map[string]string{"modules/g": ptpProgram}, nil)
|
||||
if err := ix.Apply(context.Background(), f); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
g, _ := moduleOf(t, mods, "g")
|
||||
if g.Inputs2 == nil || !slices.Contains(g.Inputs2.Packages, "git.novox.be/novox/mesh-sdk/go") {
|
||||
t.Fatalf("g = %+v, want mesh-sdk among its kept requirements", g.Inputs2)
|
||||
}
|
||||
g.Packages = nil
|
||||
mods.put("g", mustEncode(t, g))
|
||||
mods.put("mesh-sdk", mustEncode(t, meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Commit: strings.Repeat("1", 40),
|
||||
Path: meshcatalogclient.RootPath, None2: None2Pending}))
|
||||
if n, err := ix.Repin(context.Background(), "mesh-sdk"); err != nil || n != 1 {
|
||||
t.Errorf("a release of mesh-sdk re-pinned %d modules (%v), want g, which requires it with no pin", n, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,9 +609,15 @@ func (ix *Indexer) Repin(ctx context.Context, module string) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// Every kept entry naming a package of module is re-pinned, of any repository, changed or not: by its pins, and by its
|
||||
// kept requirements, which name a package it holds no pin of yet (design 47 H-A-204, H-A-165, H-A-167).
|
||||
only := map[string]bool{}
|
||||
for key, m := range held {
|
||||
for p := range m.Packages {
|
||||
names := slices.Collect(maps.Keys(m.Packages))
|
||||
if m.Inputs2 != nil {
|
||||
names = append(names, m.Inputs2.Packages...)
|
||||
}
|
||||
for _, p := range names {
|
||||
if moduleOfKey(fingerprint.HolderOf(p, held)) == module {
|
||||
only[key] = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user