mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-18 00:02:47 +00:00
Simplify netty worktree commands
Collapse the netty worktree helpers into wt create/remove/prune, keep wt-create as a thin wrapper, and drop the standalone wt-path command. Also make the netty zsh wrappers handle cd-only behavior for wtc and wt remove. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
29359546aa
commit
bc47e44ddb
5 changed files with 218 additions and 64 deletions
|
|
@ -2,28 +2,4 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
printf 'usage: wt-create <worktree-name>\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
branch_name=$1
|
||||
repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || {
|
||||
printf 'wt-create: not inside a git repository\n' >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
target_path=$(wt-path "$branch_name")
|
||||
|
||||
if [[ -e "$target_path" ]]; then
|
||||
printf 'wt-create: path already exists: %s\n' "$target_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if git -C "$repo_root" show-ref --verify --quiet "refs/heads/$branch_name"; then
|
||||
git -C "$repo_root" worktree add -- "$target_path" "$branch_name" 1>&2
|
||||
else
|
||||
git -C "$repo_root" worktree add -b "$branch_name" -- "$target_path" HEAD 1>&2
|
||||
fi
|
||||
|
||||
printf '%s\n' "$target_path"
|
||||
exec wt create "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue