(ctx context.Context, run *runtime.Runtime)
| 191 | } |
| 192 | |
| 193 | func 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 | |
| 219 | func isGitRepository(dir string) bool { |
| 220 | _, err := os.Stat(filepath.Join(dir, ".git")) |
no test coverage detected