Initial Auto-Build plugin structure
This commit is contained in:
56
plugin/scripts/worktree-list.sh
Normal file
56
plugin/scripts/worktree-list.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# List all git worktrees
|
||||
# Usage: worktree-list.sh
|
||||
|
||||
set -e
|
||||
|
||||
# Get project root (parent of .auto-build)
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
echo "========================================"
|
||||
echo " Git Worktrees"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Check if we're in a git repository
|
||||
if ! git -C "$PROJECT_ROOT" rev-parse --git-dir > /dev/null 2>&1; then
|
||||
echo "Error: Not a git repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# List all worktrees from git
|
||||
echo "Active Worktrees:"
|
||||
echo ""
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
WORKTREES=$(git worktree list --porcelain)
|
||||
|
||||
if [ -z "$WORKTREES" ]; then
|
||||
echo " No worktrees found"
|
||||
else
|
||||
git worktree list
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Show registry info if available
|
||||
REGISTRY_FILE="$PROJECT_ROOT/.auto-build-data/worktrees/worktree-registry.json"
|
||||
|
||||
if [ -f "$REGISTRY_FILE" ]; then
|
||||
echo "Auto-Build Registry:"
|
||||
echo ""
|
||||
|
||||
if command -v jq &> /dev/null; then
|
||||
jq -r '.worktrees[] | " \(.name) (\(.status))\n Branch: \(.branch)\n Path: \(.path)\n Created: \(.created)\n"' "$REGISTRY_FILE" 2>/dev/null || echo " (empty)"
|
||||
else
|
||||
cat "$REGISTRY_FILE"
|
||||
fi
|
||||
else
|
||||
echo "Registry not found. Run /ab:worktree create first."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " Create: /ab:worktree create <name>"
|
||||
echo " Cleanup: /ab:worktree cleanup [name]"
|
||||
Reference in New Issue
Block a user