From 750a486170538b546d52f7e666b01ccf82fba653 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Nov 2025 10:25:18 -0500 Subject: shorten output on untracked files --- scanRepoDir.go | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/scanRepoDir.go b/scanRepoDir.go index e8a85ef..c9c6d78 100644 --- a/scanRepoDir.go +++ b/scanRepoDir.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "github.com/destel/rill" "go.wit.com/lib/cobol" @@ -118,6 +119,8 @@ func gitDirectoriesNew(srcDir string) ([]string, error) { return nil, errors.New("SCANNING DISALBED") } var all []string + var untracked []string + var dirs []string var trip bool err := filepath.WalkDir(srcDir, func(path string, d os.DirEntry, err error) error { if err != nil { @@ -137,12 +140,21 @@ func gitDirectoriesNew(srcDir string) ([]string, error) { case "go.work.last": case "go.work.sum": default: - // todo: figure out a way to do padding for init() - if trip == false { - log.Info("WARNING:") - } - log.Info("WARNING: you have an untracked file outside of any .git repository:", path) + // log.Info("WARNING: you have an untracked file outside of any .git repository:", path) + untracked = append(untracked, path) trip = true + var match bool + for _, adir := range dirs { + if strings.HasPrefix(path, adir) { + match = true + } + } + if match { + // already have this dir + } else { + dirs = append(dirs, path) + } + } return nil } @@ -161,13 +173,17 @@ func gitDirectoriesNew(srcDir string) ([]string, error) { // because everything is either checked in or deleted. An important thing to know! if trip { log.Info("WARNING:") - log.Info("WARNING: there isn't a way to disable this warning yet") - log.Info("WARNING: probably this is a good thing however. you don't want to leave files outside of git repos here") - log.Info("WARNING: so this warning should probably stay") - log.Info("WARNING:") - log.Info("WARNING: this also might mean you put these files here because you are actively working on them") - log.Info("WARNING: and you don't want to forget about them") + log.Info("WARNING: you have files that are untracked by .git repos here") log.Info("WARNING:") + log.Printf("WARNING: you have %d untracked files %d paths\n", len(untracked), len(dirs)) + count := 0 + for _, file := range untracked { + log.Info(file) + if count > 7 { + break + } + count += 1 + } } return all, err } -- cgit v1.2.3