@samitouri / QOS-React-2 / commits / a688a3d18c

worktree script improvements (#35603)

A few small improvements: * Use `<root>/.worktrees` as the directory for worktrees so its hidden by default in finder/ls * Generate names with a timestamp, and allow auto-generating a name so that you can just call eg `./scripts/worktree.sh --compiler --claude` and get a random name

Joseph Savona committed Jan 23, 2026 at 10:41 UTC a688a3d18cfd911bf9c5e6a7ddc1af7c061b9653
2 files changed +36 -7
.gitignore
+1 -1
@@ -24,7 +24,7 @@ chrome-user-data
24 *.swp
25 *.swo
26 /tmp
27 -/worktrees
27 +/.worktrees
28 .claude/*.local.*
29
30 packages/react-devtools-core/dist
scripts/worktree.sh
+35 -6
@@ -14,12 +14,12 @@ WORKTREE_PATH=""
14
15 # --- Usage ---
16 usage() {
17 - echo "Usage: $0 <name> [--claude] [--compiler]"
17 + echo "Usage: $0 [name] [--claude] [--compiler]"
18 echo ""
19 echo "Creates a new git worktree with dependencies installed."
20 echo ""
21 echo "Arguments:"
22 - echo " <name> Name for the worktree (also used as branch name)"
22 + echo " [name] Name for the worktree (auto-generated if not provided)"
23 echo ""
24 echo "Options:"
25 echo " --claude Launch Claude Code after setup"
@@ -75,13 +75,42 @@ while [[ $# -gt 0 ]]; do
75 esac
76 done
77
78 +# Generate worktree name with timestamp prefix
79 +TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)
80 +
81 if [[ -z "$NAME" ]]; then
79 - usage
82 + # Word lists for random name generation
83 + ADJECTIVES=(
84 + "quick" "bright" "calm" "dark" "eager" "fair" "gentle" "happy" "idle" "jolly"
85 + "keen" "lively" "merry" "noble" "orange" "proud" "quiet" "rapid" "silent" "tall"
86 + "unique" "vivid" "warm" "young" "zealous" "ancient" "bold" "clever" "daring" "elegant"
87 + "fancy" "grand" "humble" "icy" "jagged" "kind" "loud" "magic" "narrow" "odd"
88 + "plain" "quaint" "rough" "sharp" "tender" "ultra" "vast" "wild" "xeric" "youthful"
89 + "zesty" "agile" "brave" "crisp" "deep"
90 + )
91 + NOUNS=(
92 + "apple" "bear" "cloud" "dragon" "eagle" "flame" "garden" "hill" "island" "jungle"
93 + "kettle" "lemon" "mountain" "night" "ocean" "panda" "quartz" "river" "storm" "tiger"
94 + "umbrella" "valley" "whale" "xenon" "yarn" "zebra" "anchor" "bridge" "canyon" "desert"
95 + "ember" "forest" "glacier" "harbor" "igloo" "jewel" "knight" "lantern" "meadow" "nebula"
96 + "oasis" "phoenix" "quest" "rocket" "shadow" "thunder" "unity" "vortex" "willow" "xylophone"
97 + "yonder" "zenith" "aurora" "beacon" "coral"
98 + )
99 +
100 + # Generate random name: worktree-yyyy-mm-dd-hh-mm-ss-<adjective>-<noun>
101 + RANDOM_ADJ=${ADJECTIVES[$RANDOM % ${#ADJECTIVES[@]}]}
102 + RANDOM_NOUN=${NOUNS[$RANDOM % ${#NOUNS[@]}]}
103 + NAME="worktree-${TIMESTAMP}-${RANDOM_ADJ}-${RANDOM_NOUN}"
104 + echo "Auto-generated worktree name: $NAME"
105 +else
106 + # Use provided name: worktree-yyyy-mm-dd-hh-mm-ss-<name>
107 + NAME="worktree-${TIMESTAMP}-${NAME}"
108 + echo "Worktree name: $NAME"
109 fi
110
111 # --- Check .gitignore ---
83 -if ! grep -qE '^/?worktrees/?$' "$REPO_ROOT/.gitignore" 2>/dev/null; then
84 - error "'worktrees' is not in .gitignore. Add it before creating worktrees."
112 +if ! grep -qE '^/?\.worktrees/?$' "$REPO_ROOT/.gitignore" 2>/dev/null; then
113 + error "'.worktrees' is not in .gitignore. Add it before creating worktrees."
114 fi
115
116 # --- Check if worktree already exists ---
@@ -90,7 +119,7 @@ if git worktree list | grep -q "\[$NAME\]"; then
119 fi
120
121 # --- Set up worktree path ---
93 -WORKTREES_DIR="$REPO_ROOT/worktrees"
122 +WORKTREES_DIR="$REPO_ROOT/.worktrees"
123 WORKTREE_PATH="$WORKTREES_DIR/$NAME"
124
125 if [[ -d "$WORKTREE_PATH" ]]; then