Repository navigation
Preserve ignored user files during merged worktree cleanup #1556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -260,12 +260,23 @@ def merges_since(wt: Path, sha: str) -> list[str]: | |
|
|
||
|
|
||
| def cleanup(wt: Path) -> None: | ||
| """Remove the worktree and its branch. Refuses when the worktree is dirty.""" | ||
| """Remove the worktree and branch if there are no local user files.""" | ||
| wt = Path(wt).absolute() | ||
| if not wt.exists(): | ||
| raise WorktreeError(f"no such worktree: {wt}") | ||
| if is_dirty(wt): | ||
| raise WorktreeError(f"worktree is dirty, refusing to remove: {wt}") | ||
| ignored = _git( | ||
| wt, "ls-files", "--others", "--ignored", "--exclude-standard", "-z", preserve_newlines=True | ||
| ) | ||
| for path in ignored.split("\0")[:-1]: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Leftover atomic-write temp files permanently block cleanup
|
||
| if ( | ||
| (path in {".loopzero/task.md", ".loopzero/checks.json"} | ||
| or re.fullmatch(r"\.loopzero/review-[0-9a-f]{12}-(primary|delta)\.json", path)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Receipt filename allowlist duplicates the naming in cli._review_file and runners The new regex |
||
| and not (wt / path).is_symlink() | ||
| ): | ||
| continue | ||
| raise WorktreeError(f"worktree contains ignored file {path!r}, refusing to remove: {wt}") | ||
| name, gd = branch(wt), (wt / _git(wt, "rev-parse", "--git-common-dir")).resolve() | ||
| _git(gd, f"--git-dir={gd}", "worktree", "remove", str(wt)) # never the primary checkout | ||
| try: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Ignored build/dependency caches now block cleanup and are fully enumerated
ls-files --others --ignoredwithout--directorywalks into every ignored tree, such as.venv/,node_modules/or__pycache__/. Two effects: (a) any developer who ran tests or installed dependencies in the task worktree now gets a refusal that names only the first file, and (b) the listing can be very large and slow under the git timeout. Refusing on these files matches the stated goal, but the warning only says "fix the cause" (cli.py:1162). Consider reporting the top-level ignored directory, or a count of ignored files, so the user can decide quickly. Also consider documenting that build caches have to be removed before cleanup.