Skip to content

Commit cdf305e

Browse files
joshsmithxrmclaude
andcommitted
chore(commands): add upstream remote fallback for worktrees
Addresses Gemini code review feedback to add fallback checking for upstream remote when origin detection fails. This improves robustness for worktrees and forks where origin may not be the primary remote. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e0137b6 commit cdf305e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.claude/commands/review-bot-comments.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Before any GitHub API operations, detect the current repo from git remote:
1515
GITHUB_REMOTE=$(git remote get-url origin 2>/dev/null)
1616
GITHUB_OWNER=$(echo "$GITHUB_REMOTE" | sed -E 's#.*(github\.com[:/])([^/]+)/.*#\2#')
1717
GITHUB_REPO=$(echo "$GITHUB_REMOTE" | sed -E 's#.*/([^/]+?)(\.git)?$#\1#')
18+
19+
# Fallback for worktrees or forks
20+
if [ -z "$GITHUB_OWNER" ]; then
21+
GITHUB_REMOTE=$(git remote get-url upstream 2>/dev/null)
22+
GITHUB_OWNER=$(echo "$GITHUB_REMOTE" | sed -E 's#.*(github\.com[:/])([^/]+)/.*#\2#')
23+
GITHUB_REPO=$(echo "$GITHUB_REMOTE" | sed -E 's#.*/([^/]+?)(\.git)?$#\1#')
24+
fi
1825
```
1926

2027
Use `$GITHUB_OWNER` and `$GITHUB_REPO` in all `gh api` calls.

.claude/commands/ship.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Before any GitHub API operations, detect the current repo from git remote:
4141
GITHUB_REMOTE=$(git remote get-url origin 2>/dev/null)
4242
GITHUB_OWNER=$(echo "$GITHUB_REMOTE" | sed -E 's#.*(github\.com[:/])([^/]+)/.*#\2#')
4343
GITHUB_REPO=$(echo "$GITHUB_REMOTE" | sed -E 's#.*/([^/]+?)(\.git)?$#\1#')
44+
45+
# Fallback for worktrees or forks
46+
if [ -z "$GITHUB_OWNER" ]; then
47+
GITHUB_REMOTE=$(git remote get-url upstream 2>/dev/null)
48+
GITHUB_OWNER=$(echo "$GITHUB_REMOTE" | sed -E 's#.*(github\.com[:/])([^/]+)/.*#\2#')
49+
GITHUB_REPO=$(echo "$GITHUB_REMOTE" | sed -E 's#.*/([^/]+?)(\.git)?$#\1#')
50+
fi
4451
```
4552

4653
Use `$GITHUB_OWNER` and `$GITHUB_REPO` in all `gh api` calls instead of hardcoded values.

0 commit comments

Comments
 (0)