mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-19 16:03:29 +00:00
fix: use WM_WORKTREE_PATH in worktree-cleanup and add debug logs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
5e415c0a12
commit
ed6aaeeea3
@@ -1,24 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Use WM_WORKTREE_PATH (set by workmux) so this works regardless of cwd
|
||||
wt_dir="${WM_WORKTREE_PATH:-.}"
|
||||
echo "[cleanup] cwd=$(pwd) WM_WORKTREE_PATH=${WM_WORKTREE_PATH:-<unset>} wt_dir=$wt_dir"
|
||||
|
||||
# Kill backend/frontend processes using this worktree's ports
|
||||
if [ -f .env.local ]; then
|
||||
source .env.local
|
||||
if [ -f "$wt_dir/.env.local" ]; then
|
||||
source "$wt_dir/.env.local"
|
||||
echo "[cleanup] .env.local found: BACKEND_PORT=${BACKEND_PORT:-<unset>} FRONTEND_PORT=${FRONTEND_PORT:-<unset>}"
|
||||
for port in "${BACKEND_PORT:-}" "${FRONTEND_PORT:-}"; do
|
||||
[ -z "$port" ] && continue
|
||||
pid=$(lsof -ti "TCP:${port}" -sTCP:LISTEN 2>/dev/null || true)
|
||||
if [ -n "$pid" ]; then
|
||||
kill "$pid" 2>/dev/null && echo "Killed process $pid on port $port" \
|
||||
|| echo "Warning: Could not kill process $pid on port $port"
|
||||
kill "$pid" 2>/dev/null && echo "[cleanup] Killed process $pid on port $port" \
|
||||
|| echo "[cleanup] Warning: Could not kill process $pid on port $port"
|
||||
else
|
||||
echo "[cleanup] No process listening on port $port"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "[cleanup] No .env.local at $wt_dir/.env.local"
|
||||
fi
|
||||
|
||||
# Remove the matching windmill-ee-private worktree if one exists
|
||||
wt_basename=$(basename "$(pwd)")
|
||||
wt_basename=$(basename "$wt_dir")
|
||||
|
||||
# Check parent directory first (sibling to worktree root), then fall back to home
|
||||
parent_dir="$(cd "$(pwd)/.." && pwd)"
|
||||
parent_dir="$(cd "$wt_dir/.." && pwd)"
|
||||
echo "[cleanup] wt_basename=$wt_basename parent_dir=$parent_dir"
|
||||
if [ -d "${parent_dir}/windmill-ee-private" ]; then
|
||||
ee_repo="${parent_dir}/windmill-ee-private"
|
||||
else
|
||||
@@ -26,8 +36,9 @@ else
|
||||
fi
|
||||
|
||||
ee_worktree_dir="${ee_repo}__worktrees/${wt_basename}"
|
||||
echo "[cleanup] ee_repo=$ee_repo ee_worktree_dir=$ee_worktree_dir exists=$([ -d "$ee_worktree_dir" ] && echo yes || echo no)"
|
||||
if [ -d "$ee_worktree_dir" ]; then
|
||||
git -C "$ee_repo" worktree remove "$ee_worktree_dir" --force 2>/dev/null \
|
||||
&& echo "Removed EE worktree at $ee_worktree_dir" \
|
||||
|| echo "Warning: Could not remove EE worktree at $ee_worktree_dir"
|
||||
&& echo "[cleanup] Removed EE worktree at $ee_worktree_dir" \
|
||||
|| echo "[cleanup] Warning: Could not remove EE worktree at $ee_worktree_dir"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user