INNER CODE UNIT · Go

cleanupWorktree

umputun/ralphex · cmd/ralphex/main.go:827

func cleanupWorktree(gitSvc *git.Service, origDir, wtPath string, preserve *atomic.Bool) {
	if chdirErr := os.Chdir(origDir); chdirErr != nil {
		fmt.Fprintf(os.Stderr, "warning: failed to restore working directory: %v\n", chdirErr)
	}
	if preserve.Load() {
		fmt.Fprintf(os.Stderr, "worktree kept at %s: the plan archive did not complete\n"+
			"inspect with git -C %s status, then git worktree remove %s before retrying this plan\n",
			wtPath, wtPath, wtPath)
		return
	}
	if rmErr := gitSvc.RemoveWorktree(wtPath); rmErr != nil {
		fmt.Fprintf(os.Stderr, "warning: failed to remove worktree: %v\n", rmErr)
	}
}

// worktreePlanFile maps an absolute plan path from the main repo onto its copy inside wtPath.
// It resolves symlinks on the plan path to match the repo root (macOS: /tmp -> /private/tmp),
// then joins the repo-relative remainder onto the worktree root, mirroring the layout

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…