Files
auto-build/plugin/scripts/worktree-switch.sh
Marius Mutu 730e5d6061 fix: Worktree scripts use $(pwd) for project root
Scripts now correctly determine project root from current working
directory instead of calculating relative to script location.
This fixes the issue when scripts are called via ${CLAUDE_PLUGIN_ROOT}.

Also adds CLAUDE.md and CHANGELOG.md for development guidance.

Bumps version to 1.0.3.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 11:07:39 +02:00

49 lines
1.4 KiB
Bash

#!/bin/bash
# Show instructions for switching to a worktree
# Usage: worktree-switch.sh <feature-name>
set -e
FEATURE_NAME="$1"
# Get project root from current working directory (where Claude Code is running)
PROJECT_ROOT="$(pwd)"
PROJECT_NAME=$(basename "$PROJECT_ROOT")
WORKTREES_DIR="$(dirname "$PROJECT_ROOT")/ab-worktrees"
if [ -z "$FEATURE_NAME" ]; then
echo "Error: Feature name required"
echo "Usage: worktree-switch.sh <feature-name>"
echo ""
echo "Available worktrees:"
ls -1 "$WORKTREES_DIR" 2>/dev/null | grep "^${PROJECT_NAME}-" | sed "s/${PROJECT_NAME}-/ /" || echo " (none)"
exit 1
fi
WORKTREE_PATH="${WORKTREES_DIR}/${PROJECT_NAME}-${FEATURE_NAME}"
if [ ! -d "$WORKTREE_PATH" ]; then
echo "Error: Worktree not found at: $WORKTREE_PATH"
echo ""
echo "Available worktrees:"
ls -1 "$WORKTREES_DIR" 2>/dev/null | grep "^${PROJECT_NAME}-" | sed "s/${PROJECT_NAME}-/ /" || echo " (none)"
exit 1
fi
echo "========================================"
echo " Switch to Worktree"
echo "========================================"
echo ""
echo "Feature: $FEATURE_NAME"
echo "Path: $WORKTREE_PATH"
echo ""
echo "To switch to this worktree, run:"
echo ""
echo " cd $WORKTREE_PATH"
echo ""
echo "Or start a new terminal/Claude Code session in that directory."
echo ""
echo "To return to main project:"
echo " cd $PROJECT_ROOT"
echo ""