// 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() } if argv.Fixer.DeleteUser { return doDeleteUser() } 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 }