Never list index.mf at the top of the tree in gen and freshen (closes #233)
check / check (push) Canceled after 0s

fetch saves the manifest as index.mf at the top of the tree and refuses a
manifest that lists a file there. gen given --output, and freshen with its
manifest outside the base directory, listed such a file, so they wrote
manifests fetch would not take.

gen now leaves out index.mf in each directory it is given, or beside each
file it is given, the same way it leaves out the file it writes. freshen
leaves out index.mf at the top of the base directory. index.mf in a
subdirectory is still listed. The README says so for both commands.

Model: opus-5-5
This commit is contained in:
2026-10-15 21:35:00 +00:00
parent 06127e291f
commit 2b692fad7c
5 changed files with 122 additions and 9 deletions
+20 -4
View File
@@ -111,15 +111,19 @@ func (mfa *CLIApp) outputPath(cmd *cli.Command) (string, error) {
return defaultManifestName, nil
}
arg := cmd.Args().First()
return mfa.topIndexMFPath(cmd.Args().First()), nil
}
// topIndexMFPath returns index.mf in the directory path names, or beside
// the file it names, which is the top of the tree gen lists for that path.
func (mfa *CLIApp) topIndexMFPath(path string) string {
// A path that does not exist is refused when it is enumerated.
info, err := mfa.Fs.Stat(arg)
info, err := mfa.Fs.Stat(path)
if err == nil && !info.IsDir() {
return filepath.Join(filepath.Dir(arg), defaultManifestName), nil
return filepath.Join(filepath.Dir(path), defaultManifestName)
}
return filepath.Join(arg, defaultManifestName), nil
return filepath.Join(path, defaultManifestName)
}
// buildScannerOptions constructs scanner options from the CLI flags and
@@ -139,6 +143,18 @@ func (mfa *CLIApp) buildScannerOptions(
ExcludePaths: []string{output, manifestTempPath(output)},
}
// Nor does index.mf at the top of the tree, since fetch saves the
// manifest there and refuses a manifest that lists it. With no path
// given, gen lists the current directory.
paths := cmd.Args().Slice()
if len(paths) == 0 {
paths = []string{"."}
}
for _, path := range paths {
opts.ExcludePaths = append(opts.ExcludePaths, mfa.topIndexMFPath(path))
}
// Set seed for deterministic UUID if provided
if seed := cmd.String("seed"); seed != "" {
opts.Seed = seed