A module's directory is never shared code, held or not (hq issue 278)
The merge of mesh-catalog 7f99fb4a rebuilt 103 modules with the build agent in tier 0, and ADR 0236 recorded it as "a change to the build agent rebuilds most of the catalogue". The agent had not changed: modules/showcase/index.ts had. showcase is the catalogue's reference module, held by no machine, and its manifest was not in the merge, so whatTheMergeTouched read the file as shared code and rebuilt everything built from the repository (88 came out byte-identical). The agent stood first only because everything is built by it. Whether a directory is a module is a fact of the repository at the merge commit, so the forge's announcer now says it: module_dirs, the changed files' directories holding a module.json there, with module_dirs_said. A changed file inside one is that module's business; only a file in no such directory is shared. An announcer that does not say keeps the old rule. `plans` what-if takes the same list as module-dirs. And a regression for the open question: nothing depends on the build agent except by being built by it, and built-by never widens a plan, so a change to the agent - manifest or program - rebuilds the agent alone; what moved beside it is ordered after it.
This commit is contained in:
@@ -1062,6 +1062,8 @@ func plansCommand(ctx context.Context, args []string) error {
|
||||
whatIf := set.String("what-if", "", "owner/repository: the plan a merge there would produce, saving nothing — with --paths or --modules")
|
||||
paths := set.String("paths", "", "the files the merge would change, comma-separated, from the repository's root")
|
||||
modules := set.String("modules", "", "or the modules it would change, comma-separated")
|
||||
moduleDirs := set.String("module-dirs", "", "with --paths: the directories holding a module.json at the commit, "+
|
||||
"comma-separated, as the forge's announcer says them (novox/hq issue 278)")
|
||||
// Ending a plan by hand is a repair, and says why (novox/hq to-be 45 §7).
|
||||
why := addHandActFlags(set)
|
||||
positionals, err := parseAround(set, args)
|
||||
@@ -1131,7 +1133,7 @@ func plansCommand(ctx context.Context, args []string) error {
|
||||
return nil
|
||||
}
|
||||
if *whatIf != "" {
|
||||
return planWhatIf(ctx, inv, *whatIf, splitList(*paths), splitList(*modules))
|
||||
return planWhatIf(ctx, inv, *whatIf, splitList(*paths), splitList(*modules), moduleDirsOf(*moduleDirs))
|
||||
}
|
||||
// `retry` (novox/hq ADR 0219): a failed plan's failed builds asked again, and the plan goes on.
|
||||
if len(positionals) == 2 && positionals[0] == "retry" {
|
||||
@@ -1194,12 +1196,15 @@ func plansCommand(ctx context.Context, args []string) error {
|
||||
// planWhatIf is the plan a merge would produce, computed the way the merge handler computes one
|
||||
// and saved nowhere: the modules the repository's changed files touch (or the modules named), what
|
||||
// packages their source, everything reachable from them, in tiers. For reading before merging.
|
||||
func planWhatIf(ctx context.Context, inv *inventory.Inventory, repository string, paths, modules []string) error {
|
||||
func planWhatIf(ctx context.Context, inv *inventory.Inventory, repository string, paths, modules []string, moduleDirs *[]string) error {
|
||||
owner, repo, found := strings.Cut(repository, "/")
|
||||
if !found {
|
||||
return fmt.Errorf("--what-if takes owner/repository, not %q", repository)
|
||||
}
|
||||
m := link.SourceMoved{Owner: owner, Repo: repo, Base: "main", Commit: "what-if", Paths: paths}
|
||||
if moduleDirs != nil {
|
||||
m.ModuleDirs, m.ModuleDirsSaid = *moduleDirs, true
|
||||
}
|
||||
entries, err := inv.Catalogued(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1275,6 +1280,16 @@ func planWhatIf(ctx context.Context, inv *inventory.Inventory, repository string
|
||||
return nil
|
||||
}
|
||||
|
||||
// moduleDirsOf is --module-dirs as an announcer would say it: nothing when not given, so the what-if
|
||||
// reads as an announcement from an announcer that does not say.
|
||||
func moduleDirsOf(s string) *[]string {
|
||||
if strings.TrimSpace(s) == "" {
|
||||
return nil
|
||||
}
|
||||
dirs := splitList(s)
|
||||
return &dirs
|
||||
}
|
||||
|
||||
func splitList(s string) []string {
|
||||
var out []string
|
||||
for _, part := range strings.Split(s, ",") {
|
||||
|
||||
Reference in New Issue
Block a user