Merge pull request 'Design 47 H1: the Go build module takes a same-repository requirement from the tree at any version and reads the repository from the fetch (H-A-202, H-A-198, H-A-204)' (#721) from fix/47-H1-build-go-same-repo into main

This commit was merged in pull request #721.
This commit is contained in:
2026-11-20 23:52:00 +00:00
7 changed files with 188 additions and 56 deletions
@@ -208,11 +208,16 @@ func (m *Module) fetchInto(ctx context.Context, req sdkstep.FetchRequest, id str
go func() {
defer wg.Done()
defer func() { <-slots }()
// The checked repository's own modules come from the fetched tree, at whatever version go.mod names them
// (pins.go takeOwnRequirements; design 47 H, S31).
if taken[i], errs[i] = m.takeOwnRequirements(root, repository, filepath.Join(tree, d), d); errs[i] != nil {
return
}
// The asked versions of the mesh's packages go into the modfile before anything is downloaded (versions.go).
if taken[i], errs[i] = m.takeVersions(ctx, root, filepath.Join(tree, d), d, req.Packages, &pins); errs[i] != nil {
more, err := m.takeVersions(ctx, root, repository, filepath.Join(tree, d), d, req.Packages, &pins)
if taken[i], errs[i] = append(taken[i], more...), err; errs[i] != nil {
return
}
var more []TakenVersion
// Then what only a module the directory replaces names, which the download would not miss (pins.go).
more, errs[i] = m.takeReplacedZeroPins(ctx, root, repository, filepath.Join(tree, d), d, req.Packages, taken[i], &pins)
if taken[i] = append(taken[i], more...); errs[i] != nil {
@@ -296,8 +296,9 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) {
return forgekey.Ran{}
}}
m, states := fetchModule(t, f)
// Asked for the module of tools, as a build is for one module (A-447b).
if _, err := fetchTool(t, m)(map[string]any{"repository": "novox/mesh-sdk", "commit": commitSHA, "dir": "tools"}); err != nil {
// Asked for the module of tools, as a build is for one module (A-447b), of a repository other than mesh-sdk's,
// whose packages its go.mod requires: one of its own repository is built from the tree (S31).
if _, err := fetchTool(t, m)(map[string]any{"repository": "novox/mesh-member", "commit": commitSHA, "dir": "tools"}); err != nil {
t.Fatal(err)
}
st := states.waitEnd(t)
@@ -22,7 +22,7 @@ var narrowedKeptAtRoot = []string{"module.json", "go.sum", "package-lock.json"}
// narrowTree narrows the fetched tree for a build of an artifact that names its paths (ADR 0499 clause 4,
// steprun.Narrow). Beside the artifact's paths and the module's manifest, the workspace holds every generated-from
// directory an artifact of the module names, and the directory (with its go.mod) of every package of the same repository
// the artifact's go.mod requires at the zero version, found by the manifests of that repository's modules; nothing else
// the artifact's go.mod requires at any version (S31), found by the manifests of that repository's modules; nothing else
// (design 47 H, lead answer H-A-136). A package of another repository comes published, as before (ADR 0573 §4).
func narrowTree(tree, repository string, req sdkstep.FetchRequest) error {
dir := cleanDir(req.Dir)
@@ -30,7 +30,7 @@ func narrowTree(tree, repository string, req sdkstep.FetchRequest) error {
return steprun.Narrow(tree, req) // refused there: named paths without the module's directory
}
extra := generatedFromDirs(tree, dir)
extra = append(extra, ownZeroPackageDirs(tree, repository, dir, req.Paths)...)
extra = append(extra, ownPackageDirs(tree, repository, dir, req.Paths)...)
var outside []string
inside := slices.Clone(req.Paths)
for _, e := range extra {
@@ -127,18 +127,19 @@ func generatedFromDirs(tree, dir string) []string {
return out
}
// ownZeroPackageDirs are the directories (from the tree's root) of the packages of the checked repository that a go.mod
// under the artifact's named paths requires at the zero version (H-A-136; ADR 0573 §2), transitively: the go.mod of each
// such directory is read in turn for the packages of the repository it requires at the zero version, each directory
// once (design 47 H, H-A-202, H-A-198). Each is found by the manifests of the repository's modules: a module's directory
// ownPackageDirs are the directories (from the tree's root) of the packages of the checked repository (the fetch's
// repository, sameRepository) that a go.mod under the artifact's named paths requires, at whatever version it names them
// (H-A-136; ADR 0573 §2; design 47 H, S31), transitively: the go.mod of each such directory is read in turn for the
// packages of the repository it requires, each directory once (design 47 H, H-A-202, H-A-198). Each is found by the manifests of the repository's modules: a module's directory
// or the directory of one of its artifacts' paths whose go.mod declares the required module path. One no manifest leads
// to is left to the fetch's resolution, which fails naming it.
func ownZeroPackageDirs(tree, repository, dir string, paths []string) []string {
func ownPackageDirs(tree, repository, dir string, paths []string) []string {
want := map[string]bool{}
addReqs := func(raw []byte) {
for _, pn := range forgePins(string(raw)) {
if pn.short == zeroShort && "novox/"+pn.repo == repository {
want[pn.module] = true
required, _ := goModRequirements(string(raw))
for module := range required {
if sameRepository(module, repository) {
want[module] = true
}
}
}
@@ -33,6 +33,7 @@ func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZero
zero := " v0.0.0-00010101000000-" + zeroShort
for _, tc := range []struct {
name, dir string
repository string // the fetch's repository, novox/mesh-delivery when empty
paths []string
files map[string]string
kept, gone []string
@@ -114,6 +115,25 @@ func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZero
kept: []string{"modules/a/state/s.go", "modules/b/builds/b.go", "modules/c/client/c.go"},
gone: []string{"modules/b/other", "modules/c/other", "modules/d"},
modules: []string{"modules/a/state"}},
// S31, L8: a package of the repository required at a real version comes along too, transitively, and "the
// repository" is the fetch's, under any owner; a package of another repository at a real version does not.
{name: "the repository's packages at a real version, under another owner", repository: "kin/app", dir: "modules/a", paths: []string{"state"},
files: map[string]string{
"modules/a/module.json": `{"module":"a","build":{"artifacts":[{"name":"state","kind":"package","language":"go","paths":["state"]}]}}`,
"modules/a/state/go.mod": "module git.novox.be/kin/app/modules/a/state\n\ngo 1.26\n\nrequire (\n\tgit.novox.be/kin/app/modules/b/builds v0.1.3\n\tgit.novox.be/novox/app/modules/d/x v0.1.3\n)\n",
"modules/a/state/s.go": "package state\n",
"modules/b/module.json": `{"module":"b","build":{"artifacts":[{"name":"builds","kind":"package","language":"go","paths":["builds"]}]}}`,
"modules/b/builds/go.mod": "module git.novox.be/kin/app/modules/b/builds\n\ngo 1.26\n\nrequire git.novox.be/kin/app/modules/c/client v0.2.0\n",
"modules/b/builds/b.go": "package builds\n",
"modules/c/module.json": `{"module":"c","build":{"artifacts":[{"name":"client","kind":"package","language":"go","paths":["client"]}]}}`,
"modules/c/client/go.mod": "module git.novox.be/kin/app/modules/c/client\n\ngo 1.26\n",
"modules/c/client/c.go": "package client\n",
"modules/d/module.json": `{"module":"d","build":{"artifacts":[{"name":"x","kind":"package","language":"go","paths":["x"]}]}}`,
"modules/d/x/go.mod": "module git.novox.be/novox/app/modules/d/x\n\ngo 1.26\n",
},
kept: []string{"modules/a/state/s.go", "modules/b/builds/b.go", "modules/c/client/c.go"},
gone: []string{"modules/d"},
modules: []string{"modules/a/state"}},
// A named path that leaves the repository is refused.
{name: "a named path that leaves the repository", dir: "mesh-grants", paths: []string{".", "../../outside"},
files: map[string]string{"mesh-grants/module.json": `{"module":"mesh-grants"}`, "mesh-grants/go.mod": "module mesh-grants\n\ngo 1.26\n"},
@@ -153,7 +173,11 @@ func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZero
}
}
}
req := sdkstep.FetchRequest{Repository: "novox/mesh-delivery", Commit: commitSHA, Dir: tc.dir, Paths: tc.paths}
repository := tc.repository
if repository == "" {
repository = "novox/mesh-delivery"
}
req := sdkstep.FetchRequest{Repository: repository, Commit: commitSHA, Dir: tc.dir, Paths: tc.paths}
err := narrowTree(tree, req.Repository, req)
if tc.refused != "" {
if err == nil || !strings.Contains(err.Error(), tc.refused) {
@@ -25,7 +25,19 @@ import (
dforgekey "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/forgekey"
)
const forgePrefix = "git.novox.be/novox/"
// goHost is the host the forge's Go modules are named under: a module of the repository <owner>/<name> has the path
// goHost+"<owner>/<name>" or one under it.
const goHost = "git.novox.be/"
const forgePrefix = goHost + "novox/"
// sameRepository says whether the Go module path lies in the repository the fetch is of (its owner/name, as the ask
// names it): the repository's root module or one nested in it (design 47 H, S31, L8: read from the fetch, never from an
// owner name written into the code).
func sameRepository(module, repository string) bool {
prefix := goHost + repository
return repository != "" && (module == prefix || strings.HasPrefix(module, prefix+"/"))
}
// zeroShort is the 12 digits a requirement at the zero version v0.0.0-00010101000000-000000000000 ends in: no commit.
const zeroShort = "000000000000"
@@ -381,10 +393,16 @@ func (m *Module) takeZeroRequirements(ctx context.Context, root, repository, dir
}
}
}
replacedBefore := ""
if modfile, ok := m.pinModfile(dir); ok {
if b, err := os.ReadFile(modfile); err == nil {
replacedBefore = string(b)
}
}
var taken []TakenVersion
for _, r := range reqs {
p := r.pin
if v := resolved[p.module]; v != "" && !strings.HasSuffix(v, zeroShort) {
if v := resolved[p.module]; (v != "" && !strings.HasSuffix(v, zeroShort)) || strings.Contains(replacedBefore, "replace "+p.module+" =>") {
continue // taken before
}
named := "v0.0.0-00010101000000-" + zeroShort
@@ -392,10 +410,10 @@ func (m *Module) takeZeroRequirements(ctx context.Context, root, repository, dir
if r.by != "" {
namedBy = "; " + namedBySaid(r.by)
}
if "novox/"+p.repo == repository {
if sameRepository(p.module, repository) {
// A module of the checked repository itself: it is in the fetched tree and nowhere else, since nothing of the
// repository is published before its merge. Every module of the tree goes in, as one may require another.
own, err := m.useOwnModules(dir, root, p.repo)
own, err := m.useOwnModules(dir, root, repository)
if err != nil {
return taken, fmt.Errorf("the requirement of %s at the zero version: %w", p.module, err)
}
@@ -431,12 +449,79 @@ func (m *Module) takeZeroRequirements(ctx context.Context, root, repository, dir
// namedBySaid says that a module dir replaces by the directory by names a package, and dir's go.mod does not.
func namedBySaid(by string) string { return "named by " + by + ", not by this go.mod" }
// ownRequirement is a requirement of a module of the checked repository in the module graph of a directory, at the
// version its go.mod names (any version): by as in zeroRequirement.
type ownRequirement struct {
module, named, by string
}
// ownRequirementsOf are the requirements of dir's module graph (its go.mod, then the go.mod of each module it replaces by
// a directory, as zeroRequirementsOf reads them) that lie in the repository the fetch is of, at whatever version they are
// named, each once, own first. One dir's go.mod replaces is left out, since its replace decides it.
func ownRequirementsOf(dir, repository string) []ownRequirement {
raw, err := os.ReadFile(filepath.Join(dir, "go.mod"))
if err != nil {
return nil
}
_, replaced := goModRequirements(string(raw))
seen := map[string]bool{}
var out []ownRequirement
add := func(gomod, by string) {
required, _ := goModRequirements(gomod)
for _, module := range slices.Sorted(maps.Keys(required)) {
if !sameRepository(module, repository) || seen[module] || replaced[module] {
continue
}
seen[module] = true
out = append(out, ownRequirement{module: module, named: required[module], by: by})
}
}
add(string(raw), "")
local := localReplaces(string(raw))
for _, module := range slices.Sorted(maps.Keys(local)) {
if b, err := os.ReadFile(filepath.Join(dir, filepath.FromSlash(local[module]), "go.mod")); err == nil {
add(string(b), local[module])
}
}
return out
}
// takeOwnRequirements takes, before anything is downloaded, every requirement of dir's module graph that lies in the
// checked repository from the fetched tree, at whatever version go.mod names it, the zero version or a real one (design
// 47 H, S3, S31; H-A-198, H-A-202): the indexer never pins it and its fingerprint takes the tree's objects, so the build
// takes the tree too and never the Go seat's published version. One no module of the tree declares fails the fetch,
// naming it.
func (m *Module) takeOwnRequirements(root, repository, dir, d string) ([]TakenVersion, error) {
reqs := ownRequirementsOf(dir, repository)
if len(reqs) == 0 {
return nil, nil
}
own, err := m.useOwnModules(dir, root, repository)
if err != nil {
return nil, fmt.Errorf("the requirements of %s: %w", repository, err)
}
var taken []TakenVersion
for _, r := range reqs {
if !slices.Contains(own, r.module) {
return taken, fmt.Errorf("the requirement of %s at %s: no module of that path is in the fetched tree of %s, and a module of the checked repository is built from its tree", r.module, r.named, repository)
}
said := "a module of the checked repository: built from its tree"
if r.by != "" {
said += "; " + namedBySaid(r.by)
}
if m.Say != nil {
m.Say("%s: %s (go.mod names %s) is built from the fetched tree of %s", d, r.module, r.named, repository)
}
taken = append(taken, TakenVersion{Dir: d, Package: r.module, Named: r.named, Built: "the fetched tree", Said: said})
}
return taken, nil
}
// useOwnModules replaces, in dir's temporary modfile, every module of the fetched tree whose path lies in the repository
// repo by its directory in the tree (once), and answers the paths of those modules. A replace of a module dir does not
// require is harmless to Go; one module of a repository requires another of it at the zero version.
func (m *Module) useOwnModules(dir, root, repo string) ([]string, error) {
// the fetch is of (sameRepository) by its directory in the tree (once), and answers the paths of those modules. A
// replace of a module dir does not require is harmless to Go; one module of a repository requires another of it.
func (m *Module) useOwnModules(dir, root, repository string) ([]string, error) {
tree := filepath.Join(root, "tree")
prefix := forgePrefix + repo
type found struct{ module, where string }
var mods []found
err := filepath.WalkDir(tree, func(path string, e fs.DirEntry, err error) error {
@@ -458,7 +543,7 @@ func (m *Module) useOwnModules(dir, root, repo string) ([]string, error) {
}
for _, line := range strings.Split(string(raw), "\n") {
if f := strings.Fields(line); len(f) == 2 && f[0] == "module" {
if mod := strings.Trim(f[1], `"`); (mod == prefix || strings.HasPrefix(mod, prefix+"/")) && filepath.Dir(path) != dir {
if mod := strings.Trim(f[1], `"`); sameRepository(mod, repository) && filepath.Dir(path) != dir {
mods = append(mods, found{mod, filepath.Dir(path)})
}
break
@@ -82,7 +82,9 @@ func newPinHarness(t *testing.T, gomod string, vendor bool, pulls string) (*pinH
func (h *pinHarness) fetch(states *keptStates) (FetchResult, sdkstep.Step) {
h.t.Helper()
if _, err := fetchTool(h.t, h.m)(fetchArgs); err != nil {
// A member of a repository other than mesh-sdk's, whose packages it pins: one of its own repository is built from the
// tree (S31).
if _, err := fetchTool(h.t, h.m)(map[string]any{"repository": "novox/mesh-member", "commit": commitSHA}); err != nil {
h.t.Fatal(err)
}
st := states.waitEnd(h.t)
@@ -405,55 +407,64 @@ func TestARequirementAtTheZeroVersionIsTakenFromItsPinOrRefused(t *testing.T) {
}
}
// A requirement at the zero version of a module of the checked repository itself (a nested module not yet published, which
// another module of the repository requires) is built from the fetched tree, and never asked of Go or the forge (issue 1921).
// A requirement of a module of the checked repository itself (a nested module not yet published, which another module of
// the repository requires) is built from the fetched tree, and never asked of Go or the forge (issue 1921), at whatever
// version go.mod names it: the zero version or a real one, which the Go seat would otherwise serve while the indexer's
// fingerprint takes the tree (design 47 H, S31; H-A-198, H-A-202). "The checked repository" is the fetch's repository as
// the ask names it, under any owner, never an owner written into the code (L8).
// Narrowed: a fetch of one artifact of a tree shaped like mesh-delivery's (modules/mesh-delivery-contracts/go/clients/<c>
// requiring modules/mesh-delivery-sdk at the zero version), asked with the module's directory and the artifact's paths,
// keeps the sdk's directory, found by its manifest, and resolves it there (design 47 H, H-A-136; live 2026-11-20,
// pipeline main.3: "no module of that path is in the fetched tree of novox/mesh-delivery").
func TestARequirementAtTheZeroVersionOfTheCheckedRepositorysOwnModuleIsTakenFromItsTree(t *testing.T) {
// requiring modules/mesh-delivery-sdk), asked with the module's directory and the artifact's paths, keeps the sdk's
// directory, found by its manifest, and resolves it there (design 47 H, H-A-136; live 2026-11-20, pipeline main.3: "no
// module of that path is in the fetched tree of novox/mesh-delivery").
func TestARequirementOfTheCheckedRepositorysOwnModuleIsTakenFromItsTree(t *testing.T) {
zero := "v0.0.0-00010101000000-" + zeroShort
for _, tc := range []struct {
name, own, ownDir, gomods string
args map[string]any
narrowed bool
name, own, ownDir, gomods, version string
args map[string]any
narrowed bool
}{
{name: "whole tree", own: "git.novox.be/novox/mesh-delivery/nested/go", ownDir: "nested/go", gomods: "go.mod\n",
{name: "whole tree", own: "git.novox.be/novox/mesh-delivery/nested/go", ownDir: "nested/go", gomods: "go.mod\n", version: zero,
args: map[string]any{"repository": "novox/mesh-delivery", "commit": commitSHA}},
{name: "whole tree, at a real version", own: "git.novox.be/novox/mesh-delivery/nested/go", ownDir: "nested/go", gomods: "go.mod\n",
version: "v0.1.3", args: map[string]any{"repository": "novox/mesh-delivery", "commit": commitSHA}},
{name: "a repository of another owner, judged by the ask's repository", own: "git.novox.be/kin/app/nested/go", ownDir: "nested/go",
gomods: "go.mod\n", version: zero, args: map[string]any{"repository": "kin/app", "commit": commitSHA}},
{name: "narrowed to an artifact's paths", own: "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk",
ownDir: "modules/mesh-delivery-sdk", gomods: "modules/mesh-delivery-contracts/go/clients/meshcatalogclient/go.mod\n",
ownDir: "modules/mesh-delivery-sdk", gomods: "modules/mesh-delivery-contracts/go/clients/meshcatalogclient/go.mod\n", version: zero,
args: map[string]any{"repository": "novox/mesh-delivery", "commit": commitSHA, "dir": "modules/mesh-delivery-contracts",
"paths": []any{"go/clients/meshcatalogclient"}}, narrowed: true},
{name: "narrowed to an artifact's paths, at a real version", own: "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk",
ownDir: "modules/mesh-delivery-sdk", gomods: "modules/mesh-delivery-contracts/go/clients/meshcatalogclient/go.mod\n", version: "v0.1.3",
args: map[string]any{"repository": "novox/mesh-delivery", "commit": commitSHA, "dir": "modules/mesh-delivery-contracts",
"paths": []any{"go/clients/meshcatalogclient"}}, narrowed: true},
} {
t.Run(tc.name, func(t *testing.T) {
zeroMod := "module fixture/member\n\ngo 1.26\n\nrequire (\n\t" + tc.own + " v0.0.0-00010101000000-" + zeroShort + "\n)\n"
h, states := newPinHarness(t, zeroMod, false, pullList)
ownMod := "module fixture/member\n\ngo 1.26\n\nrequire (\n\t" + tc.own + " " + tc.version + "\n)\n"
h, states := newPinHarness(t, ownMod, false, pullList)
h.f.gomods = tc.gomods
base := h.m.Run
h.m.Run = func(ctx context.Context, env []string, name string, args ...string) forgekey.Ran {
line := name + " " + strings.Join(args, " ")
if name == "git" && strings.Contains(line, " checkout ") && tc.narrowed {
if name == "git" && strings.Contains(line, " checkout ") {
r := base(ctx, env, name, args...)
tree := args[slices.Index(args, "-C")+1]
for f, body := range map[string]string{
"modules/mesh-delivery-sdk/go.mod": "module " + tc.own + "\n\ngo 1.26\n",
"modules/mesh-delivery-sdk/module.json": `{"module":"mesh-delivery-sdk","build":{"artifacts":[{"name":"go-sdk","kind":"package","language":"go"}]}}`,
"modules/mesh-delivery-contracts/module.json": `{"module":"mesh-delivery-contracts","build":{"artifacts":[{"name":"go-meshcatalogclient","kind":"package","language":"go","paths":["go/clients/meshcatalogclient"]}]}}`,
"modules/mesh-delivery-view/go.mod": "module git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view\n\ngo 1.26\n",
} {
files := map[string]string{tc.ownDir + "/go.mod": "module " + tc.own + "\n\ngo 1.26\n"}
if tc.narrowed {
files["modules/mesh-delivery-sdk/module.json"] = `{"module":"mesh-delivery-sdk","build":{"artifacts":[{"name":"go-sdk","kind":"package","language":"go"}]}}`
files["modules/mesh-delivery-contracts/module.json"] = `{"module":"mesh-delivery-contracts","build":{"artifacts":[{"name":"go-meshcatalogclient","kind":"package","language":"go","paths":["go/clients/meshcatalogclient"]}]}}`
files["modules/mesh-delivery-view/go.mod"] = "module git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view\n\ngo 1.26\n"
}
for f, body := range files {
os.MkdirAll(filepath.Join(tree, filepath.Dir(f)), 0o755)
os.WriteFile(filepath.Join(tree, f), []byte(body), 0o644)
}
return r
}
if name == "go" && strings.Contains(line, " mod download") && !strings.Contains(strings.Join(env, " "), "-modfile=") {
if !tc.narrowed {
trees, _ := filepath.Glob(filepath.Join(h.m.Work, "*", "tree"))
for _, tree := range trees {
os.MkdirAll(filepath.Join(tree, tc.ownDir), 0o755)
os.WriteFile(filepath.Join(tree, tc.ownDir, "go.mod"), []byte("module "+tc.own+"\n\ngo 1.26\n"), 0o644)
}
if tc.version != zero {
return forgekey.Ran{} // the Go seat serves the published version: what a build of the tree must never take
}
return forgekey.Ran{Status: 1, Stderr: "go: " + tc.own + "@v0.0.0-00010101000000-" + zeroShort + ": invalid version: unknown revision " + zeroShort + "\n"}
return forgekey.Ran{Status: 1, Stderr: "go: " + tc.own + "@" + zero + ": invalid version: unknown revision " + zeroShort + "\n"}
}
return base(ctx, env, name, args...)
}
@@ -485,6 +496,11 @@ func TestARequirementAtTheZeroVersionOfTheCheckedRepositorysOwnModuleIsTakenFrom
if h.ran(" mod download -json ") || h.ran("ls-remote") {
t.Error("a module of the checked repository was asked of Go or looked for among the pull request heads")
}
var res FetchResult
json.Unmarshal(st.Result, &res)
if len(res.Packages) != 1 || res.Packages[0].Package != tc.own || res.Packages[0].Built != "the fetched tree" || res.Packages[0].Named != tc.version {
t.Errorf("the taken versions = %+v, want %s named %s, built from the fetched tree", res.Packages, tc.own, tc.version)
}
})
}
}
@@ -58,10 +58,10 @@ type downloadInfo struct {
}
// takeVersions writes the asked versions into the modfile of dir (d in the tree) and answers what it took, one entry per
// asked package its go.mod requires. A package go.mod replaces is built as go.mod says, and said. A version that can be
// asked package its go.mod requires that is not of the checked repository repository. A package go.mod replaces is built as go.mod says, and said. A version that can be
// neither fetched nor found among the forge's pull request heads fails the fetch, naming it. pins serialises the
// laid copies a workspace's directories share.
func (m *Module) takeVersions(ctx context.Context, root, dir, d string, asked sdkstep.PackageVersions, pins *sync.Mutex) ([]TakenVersion, error) {
func (m *Module) takeVersions(ctx context.Context, root, repository, dir, d string, asked sdkstep.PackageVersions, pins *sync.Mutex) ([]TakenVersion, error) {
raw, err := os.ReadFile(filepath.Join(dir, "go.mod"))
if err != nil {
return nil, nil
@@ -77,8 +77,8 @@ func (m *Module) takeVersions(ctx context.Context, root, dir, d string, asked sd
var taken []TakenVersion
for _, pkg := range slices.Sorted(maps.Keys(asked)) {
named, ok := required[pkg]
if !ok {
continue // the module does not use it
if !ok || sameRepository(pkg, repository) {
continue // the module does not use it, or it is of the checked repository: built from its tree (takeOwnRequirements)
}
tv := TakenVersion{Dir: d, Package: pkg, Asked: asked[pkg], Named: named}
switch {