fix(completions): offer path completions and out-of-repo path remove#459
fix(completions): offer path completions and out-of-repo path remove#459
Conversation
`daft remove` and `daft rename` document worktree paths as a valid input form, but Tab on `./`, `../`, `/`, or `~/` produced no candidates and running either from outside any git repo bailed immediately with `Not inside a Git repository`, even when the argument was an absolute worktree path. Two coordinated changes: - Path completions in bash/zsh/fish stubs for `daft-remove` and `daft-rename`: short-circuits to directory completion on a path-like prefix, otherwise appends dirs alongside branch matches. Gated through a new `allows_path_completion()` helper so other rich-completion commands stay branch-only. - `run_remove` now detects "cwd is not in a repo" and resolves path args to canonical paths, discovers the owning repository from each, rejects mixed-repo argument sets, then `chdir`s to the project root so the existing branch_delete pipeline runs unchanged. Branch-name args from outside still error with the original message. Regression tests: two YAML scenarios cover contained and sibling layouts end-to-end (incl. the bare-branch error path); five unit tests pin the directory-completion stubs across shells and verify non-path-accepting rich commands stay unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/claude review |
|
Claude finished @avihut's task in 3m 29s —— View job PR Review: fix(completions): offer path completions and out-of-repo path remove
Overall AssessmentSolid fix that addresses the documented behavior gap. The
|
Three follow-ups from review of PR #459: - Apply the same out-of-repo path treatment to `daft rename` so the completion-suggested paths are usable from any cwd. Generalises `prepare_out_of_repo_remove` into `prepare_out_of_repo_paths` taking a command name for error messages; rename wraps its single source arg in a one-element Vec to reuse the helper. - Replace `COMPREPLY=( $(compgen -d -- "$cur") )` in the bash path-prefix short-circuit with `mapfile -t COMPREPLY < <(compgen -d -- "$cur")` so directory names containing whitespace land as a single COMPREPLY entry rather than being word-split on $IFS. The post-branch fallback already used `IFS=$'\n' read -r`; this fixes the missing case. - Add YAML scenarios for cross-repo path rejection (the `same repository` bail at `worktree_branch.rs:268` was previously dead from a test perspective) and for `daft rename` from outside a repo. A new bash unit assertion pins the `mapfile -t` form to keep word-splits from regressing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
daft removeanddaft renamedocument worktree paths as a valid input form, but Tab on./,../,/, or~/produced no candidates.daft remove <abs-path>from outside any git repo bailed withNot inside a Git repository, even when the path argument unambiguously named a worktree.run_removediscovers the owning repo from a path arg when cwd is outside any repo andchdirs to its project root before delegating to the existing branch-delete pipeline.Fixes #450
Test plan
mise run fmt:checkandmise run clippycleanmise run test:unit(1498 lib tests + new completion-stub tests) all greentests/manual/scenarios/branch-delete/daft-remove-outside-repo-by-path.ymlpasses (contained layout: success + bare-branch error + non-existent-path error)tests/manual/scenarios/branch-delete/daft-remove-outside-repo-sibling-layout.ymlpasses (sibling layout end-to-end)branch-delete:basic,:by-absolute-path,:by-relative-path,:by-dot, and:daft-remove-forcescenarios still pass — no regressions in inside-repo path resolutiondaft remove ./,daft remove /tmp/, anddaft remove <branch-prefix>from inside and outside a daft-managed repo🤖 Generated with Claude Code