diff options
| -rw-r--r-- | argv.go | 3 | ||||
| -rw-r--r-- | doDev.go | 42 |
2 files changed, 44 insertions, 1 deletions
@@ -89,7 +89,8 @@ type DevCmd struct { URL string `arg:"--connect" help:"forge url"` DeleteUser bool `arg:"--delete-user" help:"delete all user branches (checks for safety)"` Fix bool `arg:"--fix" help:"actually do it"` - Prune bool `arg:"--prune" help:"prune"` + Prune bool `arg:"--prune" help:"git fetch prune"` + Untracked bool `arg:"--untracked" help:"git untracked file list"` } type CleanCmd struct { @@ -6,6 +6,7 @@ package main import ( "errors" "fmt" + "path/filepath" "strings" "go.wit.com/lib/protobuf/forgepb" @@ -18,6 +19,47 @@ var ErrorNeedArgvFix error = errors.New("add --fix") // FORGE USES THESE TO RECOVER FROM WHEN TOOLKITS FAIL TO LOAD // so don't delete them func doDev() (string, error) { + if argv.Dev.Untracked { + // show untracked files + // git ls-files --others + // git ls-files --others --exclude-standard + // git ls-files --others --ignored --exclude-standard + var count int + var filelist []string + found := gitpb.NewRepos() + for repo := range me.forge.Repos.IterByNamespace() { + var err error + r, err := repo.RunQuiet([]string{"git", "ls-files", "--others"}) + if err != nil { + continue + } + if len(r.Stdout) == 0 { + continue + } + count += len(r.Stdout) + for _, fname := range r.Stdout { + filelist = append(filelist, filepath.Join(repo.FullPath, fname)) + } + repo.State = log.Sprintf("%d files", len(r.Stdout)) + found.Append(repo) + } + me.forge.PrintHumanTable(found) + log.Info("") + log.Info("You have %d files that are untracked excluded git files. They are probably junk.", count) + log.Info("") + log.Info("You can remove these files with '--fix' or list them all with '--verbose'") + log.Info("") + if argv.Fix { + log.Info("todo: unlink them") + } + if argv.Verbose { + for _, fname := range filelist { + log.Info(fname) + } + } + return "", nil + + } if argv.Dev.Prune { // git fetch --prune for repo := range me.forge.Repos.IterByNamespace() { |
