mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-18 16:02:31 +00:00
Add netty worktree helpers
Add netty-specific worktree helper commands and a zsh wrapper that creates sibling worktrees and cds into them. Also split script packaging so Darwin keeps the existing wt integration while netty gets git-worktree-based helpers. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
2a79a099c1
commit
8ad1784a82
7 changed files with 172 additions and 74 deletions
29
scripts/wt-create.sh
Normal file
29
scripts/wt-create.sh
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue