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

Function removeDirIfEmpty

worktree.go:1054–1070  ·  view source on GitHub ↗

removeDirIfEmpty will remove the supplied directory `dir` if `dir` is empty returns true if the directory was removed

(fs billy.Filesystem, dir string)

Source from the content-addressed store, hash-verified

1052// `dir` is empty
1053// returns true if the directory was removed
1054func removeDirIfEmpty(fs billy.Filesystem, dir string) (bool, error) {
1055 files, err := fs.ReadDir(dir)
1056 if err != nil {
1057 return false, err
1058 }
1059
1060 if len(files) > 0 {
1061 return false, nil
1062 }
1063
1064 err = fs.Remove(dir)
1065 if err != nil {
1066 return false, err
1067 }
1068
1069 return true, nil
1070}
1071
1072type indexBuilder struct {
1073 entries map[string]*index.Entry

Callers 2

doCleanMethod · 0.85
rmFileAndDirsIfEmptyFunction · 0.85

Calls 2

ReadDirMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…