diff --git a/cmd/mesh-controller/facts.go b/cmd/mesh-controller/facts.go index 95a99bc8..d24cc913 100644 --- a/cmd/mesh-controller/facts.go +++ b/cmd/mesh-controller/facts.go @@ -414,7 +414,9 @@ func gatherFacts(ctx context.Context, open *stores, busVersion string) (snapshot // The module's own build source is said apart: a gate that predates it would read an own // entry among Reads as a context of its own repository. if r.Own { - mod.Sources = append(mod.Sources, snapshot.BuildSource{Own: true, Paths: r.Paths}) + if len(r.Paths) > 0 { + mod.Sources = append(mod.Sources, snapshot.BuildSource{Own: true, Paths: r.Paths}) + } continue } mod.Reads = append(mod.Reads, snapshot.RepositoryName(r.Repository)) diff --git a/cmd/mesh-controller/planner_rules_test.go b/cmd/mesh-controller/planner_rules_test.go index 3e07a6d1..69ed505f 100644 --- a/cmd/mesh-controller/planner_rules_test.go +++ b/cmd/mesh-controller/planner_rules_test.go @@ -664,6 +664,12 @@ func TestAPlanSaysWhyEachModuleIsInIt(t *testing.T) { "read whole: no build source recorded, so every file of its repository is its build source"}, {"nothing recorded, in its directory", gitea, nil, merge("mesh-catalog", "modules/gitea/index.ts"), "read whole: no build source recorded, so its directory is its build source; e.g. modules/gitea/index.ts"}, + {"a root manifest is not in a module's directory", gitea, nil, merge("mesh-catalog", "module.json", "modules/gitea/x.ts"), + "read whole: no build source recorded, so its directory is its build source; e.g. modules/gitea/x.ts"}, + {"a context on another branch says nothing of this one", agent, map[string][]inventory.ReadRepository{"build-agent": { + {Repository: "novox/mesh-controller", Ref: "release", Paths: []string{"internal/link/"}}, + {Repository: "novox/mesh-controller", Ref: "main"}}}, merge("mesh-controller", "internal/link/handacts.go"), + "read whole: no build source recorded, so every file of novox/mesh-controller, which its build context is, is its build source"}, {"files not all said", controller, read, link.SourceMoved{Owner: "novox", Repo: "mesh-controller", PathsTruncated: true, Paths: []string{"x"}}, "read whole: the merge's changed files were not all said"}, } { diff --git a/cmd/mesh-controller/release_plan.go b/cmd/mesh-controller/release_plan.go index e21b361c..70570eea 100644 --- a/cmd/mesh-controller/release_plan.go +++ b/cmd/mesh-controller/release_plan.go @@ -1567,6 +1567,7 @@ func planWhatIf(ctx context.Context, inv *inventory.Inventory, repository string return err } var from, packaging []inventory.Entry + deleted := map[string]bool{} named := map[string]bool{} for _, name := range modules { named[name] = true @@ -1576,6 +1577,9 @@ func planWhatIf(ctx context.Context, inv *inventory.Inventory, repository string // request's check ask it (novox/hq ADR 0238). r := reachOfMerge(m, entries, read, nil) from, packaging = append(append([]inventory.Entry{}, r.Touched...), r.Deleted...), r.Packaging + for _, e := range r.Deleted { + deleted[e.Manifest.Module] = true + } } else { for _, e := range entries { switch { @@ -1609,6 +1613,9 @@ func planWhatIf(ctx context.Context, inv *inventory.Inventory, repository string if len(named) == 0 { for _, e := range from { why[e.Manifest.Module] = whyMoved(e, read[e.Manifest.Module], m) + if deleted[e.Manifest.Module] { + why[e.Manifest.Module] = "its manifest is removed: deleted at its source, forgotten where nothing holds it, not built" + } } } rolls := map[string]string{} diff --git a/cmd/mesh-controller/upgrades.go b/cmd/mesh-controller/upgrades.go index 74261bc8..8ad71f1a 100644 --- a/cmd/mesh-controller/upgrades.go +++ b/cmd/mesh-controller/upgrades.go @@ -633,14 +633,14 @@ func whyMoved(e inventory.Entry, read []inventory.ReadRepository, m link.SourceM return "read whole: " + whole + ", so every file of its repository is its build source" } for _, p := range m.Paths { - if p == moduleManifestFile || inside(p, dir) { + if inside(p, dir) { return "read whole: " + whole + ", so its directory is its build source; e.g. " + p } } return "read whole: " + whole } for _, r := range read { - if r.Own || !sameRepository(r.Repository, m) { + if r.Own || !sameRepository(r.Repository, m) || (r.Ref != "" && r.Ref != m.Base) { continue } if len(r.Paths) > 0 {