MCPcopy
hub / github.com/go-git/go-git / Clean

Method Clean

worktree.go:830–842  ·  view source on GitHub ↗

Clean the worktree by removing untracked files. An empty dir could be removed - this is what `git clean -f -d .` does.

(opts *CleanOptions)

Source from the content-addressed store, hash-verified

828// Clean the worktree by removing untracked files.
829// An empty dir could be removed - this is what `git clean -f -d .` does.
830func (w *Worktree) Clean(opts *CleanOptions) error {
831 s, err := w.Status()
832 if err != nil {
833 return err
834 }
835
836 root := ""
837 files, err := w.Filesystem.ReadDir(root)
838 if err != nil {
839 return err
840 }
841 return w.doClean(s, opts, root, files)
842}
843
844func (w *Worktree) doClean(status Status, opts *CleanOptions, dir string, files []os.FileInfo) error {
845 for _, fi := range files {

Callers 15

BenchmarkObjectsFunction · 0.80
inFilesFunction · 0.80
buildFilePathMapFunction · 0.80
TestCleanMethod · 0.80
TestCleanBareMethod · 0.80
doAddDirectoryMethod · 0.80
doAddMethod · 0.80
TearDownTestMethod · 0.80
BenchmarkPackfileIterFunction · 0.80
ModuleMethod · 0.80

Calls 3

StatusMethod · 0.95
doCleanMethod · 0.95
ReadDirMethod · 0.45

Tested by 10

BenchmarkObjectsFunction · 0.64
TestCleanMethod · 0.64
TestCleanBareMethod · 0.64
BenchmarkPackfileIterFunction · 0.64
BenchmarkParseFunction · 0.64
BenchmarkParseBasicFunction · 0.64
BenchmarkParserFunction · 0.64
BenchmarkDecodeFunction · 0.64