diff options
Diffstat (limited to 'doFix.go')
| -rw-r--r-- | doFix.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/doFix.go b/doFix.go new file mode 100644 index 0000000..eb9df32 --- /dev/null +++ b/doFix.go @@ -0,0 +1,64 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "path/filepath" + + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +// is every repo on the devel branch? +func doFix() (string, error) { + if argv.Fixer.Urls { + err := doFixUrls() + return "", err + } + if argv.Fixer.Untracked { + return doRemoveUntrackedFiles() + } + return "", nil +} + +func doRemoveUntrackedFiles() (string, error) { + // 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.Force { + log.Info("todo: unlink them") + } + if argv.Verbose { + for _, fname := range filelist { + log.Info(fname) + } + } + return "use --force to actually remove them", nil +} |
