check always warns about files the manifest does not list (closes #103)
check / check (push) Failing after 2s
check / check (push) Failing after 2s
check now always looks under the base directory for files the manifest does not list, hidden files and directories included, and prints one warning per file. The result still depends only on the listed files; --no-extra-files turns each unlisted file into a failure, and --quiet hides the warnings but not the failures. A directory that cannot be searched is likewise only a warning unless that flag is given. The manifest itself is left out by file identity, as gen and freshen do, so no name or spelling of its path or of the base gets it reported. Model: opus-5-5
This commit is contained in:
+17
-9
@@ -206,28 +206,33 @@ func countCheckFailures(
|
||||
}
|
||||
|
||||
// findExtraFiles reports files present on disk but absent from the
|
||||
// manifest, counting each as a failure.
|
||||
// manifest: each is a failure under --no-extra-files, otherwise a warning.
|
||||
func findExtraFiles(ctx *cli.Context, chk *mfer.Checker, failures *int64) error {
|
||||
extraResults := make(chan mfer.Result, 1)
|
||||
extraDone := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
for result := range extraResults {
|
||||
*failures++
|
||||
if ctx.Bool("no-extra-files") {
|
||||
*failures++
|
||||
|
||||
log.Infof("%s: %s (%s)", result.Status, result.Path, result.Message)
|
||||
log.Infof("%s: %s (%s)", result.Status, result.Path, result.Message)
|
||||
} else {
|
||||
log.Warnf("%s: %s (%s)", result.Status, result.Path, result.Message)
|
||||
}
|
||||
}
|
||||
|
||||
close(extraDone)
|
||||
}()
|
||||
|
||||
err := chk.FindExtraFiles(ctx.Context, extraResults)
|
||||
|
||||
<-extraDone
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check for extra files: %w", err)
|
||||
}
|
||||
|
||||
<-extraDone
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -270,12 +275,15 @@ func runCheck(ctx *cli.Context, chk *mfer.Checker, showProgress bool) (int64, er
|
||||
// Wait for results processing to complete
|
||||
<-done
|
||||
|
||||
// Check for extra files if requested
|
||||
if ctx.Bool("no-extra-files") {
|
||||
err = findExtraFiles(ctx, chk, &failures)
|
||||
if err != nil {
|
||||
// Without --no-extra-files the result depends only on the files the
|
||||
// manifest lists, so failing to look for others is only a warning.
|
||||
err = findExtraFiles(ctx, chk, &failures)
|
||||
if err != nil {
|
||||
if ctx.Bool("no-extra-files") {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
log.Warn(err.Error())
|
||||
}
|
||||
|
||||
return failures, nil
|
||||
|
||||
Reference in New Issue
Block a user