mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-13 06:06:38 +00:00
The default base was /tmp, which is tmpfs on this host: a reboot took a whole worktree and its uncommitted work with it. Derive the base from the origin remote instead, as ~/.local/share/worktrees/<domain>/<account>/<repo>, and let the branch keep its slashes so it nests, which also makes the infinito-wt- prefix redundant. Without an origin remote it now fails loudly rather than inventing a location. up.sh bumped only INFINITO_SWARM_LAB_SUBNET per slot while the five swarm lab node IPs stayed at default.env's 192.168.244.x, so every worktree from slot 1 on got a lab network in a different /24 than the nodes it places in it, and collided with the primary checkout's lab. Pin all six values from one octet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
52 lines
1.4 KiB
Bash
Executable File
52 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
#
|
|
# Tear down the worktree a branch was checked out into: stop its compose
|
|
# stack, then release the checkout and free its slot. Refuses to drop a
|
|
# worktree with uncommitted changes unless force=true is passed.
|
|
#
|
|
# Use `make worktree-down` rather than calling this script directly.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
|
|
|
|
# shellcheck source=scripts/system/worktree/lib.sh
|
|
source "${SCRIPT_DIR}/lib.sh"
|
|
|
|
branch="${1:?branch name required}"
|
|
base="${2:-}"
|
|
force="${3:-false}"
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
base="${base:-$(worktree_default_base)}"
|
|
path="$(worktree_path "${branch}" "${base}")"
|
|
|
|
if [ ! -d "${path}" ]; then
|
|
echo "FAILURE: no worktree at ${path} for branch '${branch}'" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "${force}" != "true" ] && [ -n "$(git -C "${path}" status --porcelain)" ]; then
|
|
echo "FAILURE: ${path} has uncommitted changes; commit them or pass force=true" >&2
|
|
git -C "${path}" status --short >&2
|
|
exit 1
|
|
fi
|
|
|
|
slot="$(worktree_slot_of "${path}")"
|
|
echo ">>> Stopping the compose stack in ${path} (slot ${slot})"
|
|
if ! make -C "${path}" compose-down; then
|
|
echo ">>> WARNING: compose-down failed; removing the worktree anyway"
|
|
fi
|
|
|
|
echo ">>> Removing worktree ${path}"
|
|
if [ "${force}" = "true" ]; then
|
|
git worktree remove --force "${path}"
|
|
else
|
|
git worktree remove "${path}"
|
|
fi
|
|
|
|
echo "Slot ${slot} released."
|