mirror of
https://github.com/navidrome/navidrome.git
synced 2026-04-26 10:30:46 +00:00
build(worktree): add script for setting up git worktrees
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
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
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
a83ebd1c98
commit
b5164c61ab
3 changed files with 92 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -37,4 +37,5 @@ AGENTS.md
|
|||
*.wasm
|
||||
*.ndp
|
||||
openspec/
|
||||
go.work*
|
||||
go.work*
|
||||
.worktrees/
|
||||
33
Makefile
33
Makefile
|
|
@ -233,6 +233,39 @@ get-music: ##@Development Download some free music from Navidrome's demo instanc
|
|||
.PHONY: get-music
|
||||
|
||||
|
||||
##########################################
|
||||
#### Worktrees
|
||||
|
||||
WORKTREES_DIR := .worktrees
|
||||
|
||||
wt: check_go_env ##@Worktrees Create and setup a git worktree. Usage: make wt name=feature-name [go=1]
|
||||
@if [ -z "${name}" ]; then echo "Usage: make wt name=<branch-name> [go=1]"; exit 1; fi
|
||||
@mkdir -p $(WORKTREES_DIR)
|
||||
@echo "Creating worktree for branch '${name}'..."
|
||||
@git worktree add $(WORKTREES_DIR)/${name} -b ${name} 2>/dev/null || \
|
||||
git worktree add $(WORKTREES_DIR)/${name} ${name}
|
||||
@if [ -n "${go}" ]; then \
|
||||
./scripts/setup-worktree.sh $(WORKTREES_DIR)/${name} --go-only; \
|
||||
else \
|
||||
./scripts/setup-worktree.sh $(WORKTREES_DIR)/${name}; \
|
||||
fi
|
||||
@echo "\nWorktree ready at $(WORKTREES_DIR)/${name}"
|
||||
@echo " cd $(WORKTREES_DIR)/${name}"
|
||||
.PHONY: wt
|
||||
|
||||
rm-wt: ##@Worktrees Remove a git worktree. Usage: make rm-wt name=feature-name
|
||||
@if [ -z "${name}" ]; then echo "Usage: make rm-wt name=<branch-name>"; exit 1; fi
|
||||
@if [ ! -d "$(WORKTREES_DIR)/${name}" ]; then echo "Worktree '${name}' not found in $(WORKTREES_DIR)/"; exit 1; fi
|
||||
@echo "Removing worktree '${name}'..."
|
||||
@git worktree remove --force $(WORKTREES_DIR)/${name}
|
||||
@echo "Worktree '${name}' removed."
|
||||
@echo "Note: branch '${name}' still exists. Delete it with: git branch -D ${name}"
|
||||
.PHONY: rm-wt
|
||||
|
||||
ls-wt: ##@Worktrees List all active git worktrees
|
||||
@git worktree list
|
||||
.PHONY: ls-wt
|
||||
|
||||
##########################################
|
||||
#### Miscellaneous
|
||||
|
||||
|
|
|
|||
57
scripts/setup-worktree.sh
Executable file
57
scripts/setup-worktree.sh
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue