MCPcopy Create free account
hub / github.com/go-git/go-git / Clean

Method Clean

worktree.go:857–869  ·  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

855// Clean the worktree by removing untracked files.
856// An empty dir could be removed - this is what `git clean -f -d .` does.
857func (w *Worktree) Clean(opts *CleanOptions) error {
858 s, err := w.Status()
859 if err != nil {
860 return err
861 }
862
863 root := ""
864 files, err := w.Filesystem.ReadDir(root)
865 if err != nil {
866 return err
867 }
868 return w.doClean(s, opts, root, files)
869}
870
871func (w *Worktree) doClean(status Status, opts *CleanOptions, dir string, files []os.FileInfo) error {
872 for _, fi := range files {

Callers 13

BenchmarkObjectsFunction · 0.80
TestCleanMethod · 0.80
TestCleanBareMethod · 0.80
doAddDirectoryMethod · 0.80
TearDownTestMethod · 0.80
BenchmarkPackfileIterFunction · 0.80
BenchmarkParseFunction · 0.80
BenchmarkParseBasicFunction · 0.80
BenchmarkParserFunction · 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