navidrome/scripts/setup-worktree.sh
Deluan b5164c61ab
Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Failing after 5s
Pipeline: Test, Lint, Build / Lint Go code (push) Failing after 5s
Pipeline: Test, Lint, Build / Test Go code (push) Failing after 3s
Pipeline: Test, Lint, Build / Test JS code (push) Failing after 3s
Pipeline: Test, Lint, Build / Lint i18n files (push) Failing after 3s
Pipeline: Test, Lint, Build / Check Docker configuration (push) Successful in 2s
Pipeline: Test, Lint, Build / Build (push) Has been skipped
Pipeline: Test, Lint, Build / Build-1 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-2 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-3 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-4 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-5 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-6 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-7 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-8 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-9 (push) Has been skipped
Pipeline: Test, Lint, Build / Build-10 (push) Has been skipped
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been skipped
Pipeline: Test, Lint, Build / Package/Release (push) Has been skipped
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been skipped
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been skipped
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been skipped
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been skipped
build(worktree): add script for setting up git worktrees
Signed-off-by: Deluan <deluan@navidrome.org>
2026-03-17 21:34:00 -04:00

57 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Setup a git worktree for Navidrome development.
# This script is called automatically by `make worktree` and by Claude Code's
# worktree isolation, but can also be run standalone:
#
# ./scripts/setup-worktree.sh <worktree-path> [--go-only]
#
# Options:
# --go-only Skip frontend (npm) setup. Useful for agents working only on Go code.
#
set -euo pipefail
WORKTREE_PATH="${1:?Usage: $0 <worktree-path> [--go-only]}"
GO_ONLY="${2:-}"
# Resolve the main worktree root (where the original repo lives)
MAIN_WORKTREE="$(git -C "$WORKTREE_PATH" worktree list --porcelain | head -1 | sed 's/^worktree //')"
if [ ! -d "$WORKTREE_PATH" ]; then
echo "ERROR: Worktree path does not exist: $WORKTREE_PATH"
exit 1
fi
cd "$WORKTREE_PATH"
echo "==> Setting up worktree at $WORKTREE_PATH"
# 1. Download Go dependencies
echo "==> Downloading Go dependencies..."
go mod download
# 2. Install frontend dependencies (unless --go-only)
if [ "$GO_ONLY" != "--go-only" ]; then
echo "==> Installing frontend dependencies..."
(cd ui && npm ci --prefer-offline --no-audit 2>/dev/null || npm ci)
else
echo "==> Skipping frontend setup (--go-only)"
fi
# 3. Create required directories
mkdir -p data
# 4. Copy navidrome.toml from main worktree if it exists and not already present
if [ ! -f navidrome.toml ] && [ -f "$MAIN_WORKTREE/navidrome.toml" ]; then
echo "==> Copying navidrome.toml from main worktree..."
cp "$MAIN_WORKTREE/navidrome.toml" navidrome.toml
fi
# 5. Copy existing database from main worktree (already migrated and scanned)
# This is much faster than running migrations + a full scan from scratch.
if [ ! -f data/navidrome.db ] && [ -f "$MAIN_WORKTREE/data/navidrome.db" ]; then
echo "==> Copying database from main worktree (pre-migrated, pre-scanned)..."
cp "$MAIN_WORKTREE/data/navidrome.db" data/navidrome.db
fi
echo "==> Worktree setup complete: $WORKTREE_PATH"