MCPcopy
hub / github.com/Jguer/yay / cleanUntracked

Function cleanUntracked

clean.go:193–217  ·  view source on GitHub ↗
(ctx context.Context, run *runtime.Runtime)

Source from the content-addressed store, hash-verified

191}
192
193func cleanUntracked(ctx context.Context, run *runtime.Runtime) error {
194 run.Logger.Println(gotext.Get("removing untracked AUR files from cache..."))
195
196 files, err := os.ReadDir(run.Cfg.BuildDir)
197 if err != nil {
198 return err
199 }
200
201 for _, file := range files {
202 if !file.IsDir() {
203 continue
204 }
205
206 dir := filepath.Join(run.Cfg.BuildDir, file.Name())
207 run.Logger.Debugln("cleaning", dir)
208 if isGitRepository(dir) {
209 if err := run.CmdBuilder.Show(run.CmdBuilder.BuildGitCmd(ctx, dir, "clean", "-fx")); err != nil {
210 run.Logger.Warnln(gotext.Get("Unable to clean:"), dir)
211 return err
212 }
213 }
214 }
215
216 return nil
217}
218
219func isGitRepository(dir string) bool {
220 _, err := os.Stat(filepath.Join(dir, ".git"))

Callers 1

syncCleanFunction · 0.85

Calls 8

isGitRepositoryFunction · 0.85
PrintlnMethod · 0.80
DebuglnMethod · 0.80
WarnlnMethod · 0.80
GetMethod · 0.65
ShowMethod · 0.65
BuildGitCmdMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected