-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgwt.sh
More file actions
executable file
·39 lines (30 loc) · 1.01 KB
/
gwt.sh
File metadata and controls
executable file
·39 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Add a git worktree for an issue number (uses gh to resolve the branch)
if [ -z "$1" ]; then
echo "Usage: gwt.sh <issue-number>"
echo "Example: gwt.sh 97"
exit 1
fi
issue_num="$1"
branches=$(gh issue develop "$issue_num" --list 2>/dev/null | awk '{print $1}')
if [ -z "$branches" ]; then
echo "No branch found for issue #$issue_num. Creating one via gh..."
gh issue develop "$issue_num"
branches=$(gh issue develop "$issue_num" --list 2>/dev/null | awk '{print $1}')
if [ -z "$branches" ]; then
echo "Failed to create branch for issue #$issue_num."
exit 1
fi
fi
branch_count=$(echo "$branches" | wc -l)
if [ "$branch_count" -gt 1 ]; then
echo "Multiple branches found for issue #$issue_num:"
echo "$branches"
exit 1
fi
branch_name="$branches"
echo "Found branch: $branch_name"
echo "Fetching from origin..."
git fetch origin "$branch_name"
echo "Creating worktree at ../worktrees/$issue_num..."
git worktree add --track -b "$branch_name" "../worktrees/$issue_num" "origin/$branch_name"