MCPcopy Index your code
hub / github.com/celer-pkg/celer / Clean

Function Clean

pkgs/git/control.go:318–339  ·  view source on GitHub ↗

Clean clean git repo.

(target, repoDir string)

Source from the content-addressed store, hash-verified

316
317// Clean clean git repo.
318func Clean(target, repoDir string) error {
319 if !fileio.PathExists(repoDir) {
320 return errors.ErrDirNotExist
321 }
322 if !fileio.PathExists(filepath.Join(repoDir, ".git")) {
323 return errors.ErrNotGitDir
324 }
325
326 var commands []string
327 commands = append(commands, "git reset --hard")
328 commands = append(commands, "git clean -ffdx")
329
330 title := fmt.Sprintf("[clean %s]", target)
331 commandLine := strings.Join(commands, " && ")
332 executor := cmd.NewExecutor(title, commandLine)
333 executor.SetWorkDir(repoDir)
334 if output, err := executor.ExecuteOutputLive(); err != nil {
335 return fmt.Errorf("failed to clean '%s' -> %s -> %w", target, output, err)
336 }
337
338 return nil
339}
340
341// HardReset hard resets the repo to the given commit and cleans untracked files.
342// If the commit is not available locally, it fetches from origin first.

Callers 1

CleanMethod · 0.92

Calls 5

PathExistsFunction · 0.92
NewExecutorFunction · 0.92
SprintfMethod · 0.80
SetWorkDirMethod · 0.80
ExecuteOutputLiveMethod · 0.80

Tested by

no test coverage detected