(status Status, opts *CleanOptions, dir string, files []os.FileInfo)
| 842 | } |
| 843 | |
| 844 | func (w *Worktree) doClean(status Status, opts *CleanOptions, dir string, files []os.FileInfo) error { |
| 845 | for _, fi := range files { |
| 846 | if fi.Name() == GitDirName { |
| 847 | continue |
| 848 | } |
| 849 | |
| 850 | // relative path under the root |
| 851 | path := filepath.Join(dir, fi.Name()) |
| 852 | if fi.IsDir() { |
| 853 | if !opts.Dir { |
| 854 | continue |
| 855 | } |
| 856 | |
| 857 | subfiles, err := w.Filesystem.ReadDir(path) |
| 858 | if err != nil { |
| 859 | return err |
| 860 | } |
| 861 | err = w.doClean(status, opts, path, subfiles) |
| 862 | if err != nil { |
| 863 | return err |
| 864 | } |
| 865 | } else { |
| 866 | if status.IsUntracked(path) { |
| 867 | if err := w.Filesystem.Remove(path); err != nil { |
| 868 | return err |
| 869 | } |
| 870 | } |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | if opts.Dir && dir != "" { |
| 875 | _, err := removeDirIfEmpty(w.Filesystem, dir) |
| 876 | return err |
| 877 | } |
| 878 | |
| 879 | return nil |
| 880 | } |
| 881 | |
| 882 | // GrepResult is structure of a grep result. |
| 883 | type GrepResult struct { |
no test coverage detected