(status Status, opts *CleanOptions, dir string, files []os.FileInfo)
| 869 | } |
| 870 | |
| 871 | func (w *Worktree) doClean(status Status, opts *CleanOptions, dir string, files []os.FileInfo) error { |
| 872 | for _, fi := range files { |
| 873 | if fi.Name() == GitDirName { |
| 874 | continue |
| 875 | } |
| 876 | |
| 877 | // relative path under the root |
| 878 | path := filepath.Join(dir, fi.Name()) |
| 879 | if fi.IsDir() { |
| 880 | if !opts.Dir { |
| 881 | continue |
| 882 | } |
| 883 | |
| 884 | subfiles, err := w.Filesystem.ReadDir(path) |
| 885 | if err != nil { |
| 886 | return err |
| 887 | } |
| 888 | err = w.doClean(status, opts, path, subfiles) |
| 889 | if err != nil { |
| 890 | return err |
| 891 | } |
| 892 | } else { |
| 893 | if status.IsUntracked(path) { |
| 894 | if err := w.Filesystem.Remove(path); err != nil { |
| 895 | return err |
| 896 | } |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | if opts.Dir && dir != "" { |
| 902 | _, err := removeDirIfEmpty(w.Filesystem, dir) |
| 903 | return err |
| 904 | } |
| 905 | |
| 906 | return nil |
| 907 | } |
| 908 | |
| 909 | // GrepResult is structure of a grep result. |
| 910 | type GrepResult struct { |
no test coverage detected