MCPcopy
hub / github.com/git-lfs/git-lfs / Cleanup

Method Cleanup

t/cmd/util/testutils.go:151–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149}
150
151func (r *Repo) Cleanup() {
152 // pop out if necessary
153 r.Popd()
154
155 // Make sure cwd isn't inside a path we're going to delete
156 oldwd, err := os.Getwd()
157 if err == nil {
158 if strings.HasPrefix(oldwd, r.Path) ||
159 strings.HasPrefix(oldwd, r.GitDir) {
160 os.Chdir(os.TempDir())
161 }
162 }
163
164 if r.GitDir != "" {
165 os.RemoveAll(r.GitDir)
166 r.GitDir = ""
167 }
168 if r.Path != "" {
169 os.RemoveAll(r.Path)
170 r.Path = ""
171 }
172 for _, remote := range r.Remotes {
173 remote.Cleanup()
174 }
175 r.Remotes = nil
176}
177
178// NewRepo creates a new git repo in a new temp dir
179func NewRepo(callback RepoCallback) *Repo {

Callers 15

TestScanUnpushedFunction · 0.95
TestScanPreviousVersionsFunction · 0.95
TestRecentBranchesFunction · 0.95
TestWorktreesFunction · 0.95
TestGitAndRootDirsFunction · 0.95
TestGetTrackedFilesFunction · 0.95
TestLocalRefsFunction · 0.95
TestGetFilesChangesFunction · 0.95

Calls 3

PopdMethod · 0.95
RemoveAllMethod · 0.80
TempDirMethod · 0.45

Tested by 14

TestScanUnpushedFunction · 0.76
TestScanPreviousVersionsFunction · 0.76
TestRecentBranchesFunction · 0.76
TestWorktreesFunction · 0.76
TestGitAndRootDirsFunction · 0.76
TestGetTrackedFilesFunction · 0.76
TestLocalRefsFunction · 0.76
TestGetFilesChangesFunction · 0.76