The delivery repository's contracts and SDK live under modules/ as mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths renamed to match the folders (the TypeScript names already did), and every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools and mesh-sdk follows in the same group: a design as it should be, one path per module, checked by the group's check building every importer. Builds: design 47 G §427, §88 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
66 lines
2.7 KiB
Go
66 lines
2.7 KiB
Go
// Package grouppackages is the one place that names the versions a build at a delivery group's heads uses (novox/hq
|
|
// ADR 0573 §2, §4; issue 1921). A build writes into its workspace the version of every mesh package it is asked, whatever
|
|
// its go.mod names; a requirement at the zero version that no ask names a commit for cannot be fetched. So every part
|
|
// that asks a build for a check, a try or a candidate (the checker's check, judge and compose asks, the indexer's
|
|
// candidate modules) takes the versions from Heads, and a member of the group that publishes no package yet is named too.
|
|
package grouppackages
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/sdkversion"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
|
|
)
|
|
|
|
// rootOf is the module a member of repo stands for when no package of it is known: its root module path, or for the
|
|
// repository of mesh-sdk its Go module (sdkversion.Module, which is not at the root).
|
|
func rootOf(repo string) (string, bool) {
|
|
if sdkRepo, _, ok := trunk.PackageRepository(sdkversion.Module); ok && trunk.SameRepository(repo, sdkRepo) {
|
|
return sdkversion.Module, true
|
|
}
|
|
name, found := strings.CutPrefix(repo, "novox/")
|
|
if !found || name == "" {
|
|
return "", false
|
|
}
|
|
return trunk.ForgeModulePrefix + name, true
|
|
}
|
|
|
|
// Heads is the version of each mesh package a build of own builds against: latest (the latest published version of each
|
|
// package the mesh's modules use, nil for none) with every package of a group member at that member's head (heads, by
|
|
// repository <owner>/<name>, a full commit each), and for a member of which latest holds no package, the member's root
|
|
// module path (mesh-sdk's Go module for mesh-sdk) at its head: the build module takes the head of a
|
|
// repository from any package of it. A package of own comes with the tree the build fetched, and is left out, as is a
|
|
// package no version is known of. Nil for none. latest is not changed.
|
|
func Heads(latest buildstep.PackageVersions, heads map[string]string, own string) buildstep.PackageVersions {
|
|
versions := buildstep.PackageVersions{}
|
|
held := map[string]bool{}
|
|
for pkg, version := range latest {
|
|
repo, _, ok := trunk.PackageRepository(pkg)
|
|
if !ok || trunk.SameRepository(repo, own) {
|
|
continue
|
|
}
|
|
if head := heads[repo]; len(head) == 40 {
|
|
version = head
|
|
}
|
|
if version == "" {
|
|
continue
|
|
}
|
|
versions[pkg] = version
|
|
held[repo] = true
|
|
}
|
|
for repo, head := range heads {
|
|
if trunk.SameRepository(repo, own) || len(head) != 40 || held[repo] {
|
|
continue
|
|
}
|
|
if root, ok := rootOf(repo); ok {
|
|
versions[root] = head
|
|
}
|
|
}
|
|
if len(versions) == 0 {
|
|
return nil
|
|
}
|
|
return versions
|
|
}
|