From 8e28464bdf745f539a9aeac499a37e8ac666818b Mon Sep 17 00:00:00 2001 From: DJP Date: Sat, 16 May 2026 13:47:03 -0400 Subject: [PATCH] deploy.sh: fix self-collision in slug check when clone path != slug The collision check filtered self-matches by /opt/${SLUG}/, which only works when the on-disk directory matches the URL slug. When the repo is cloned to a different directory (e.g. /opt/loreal-utilisation-dept/ to match the Bitbucket repo name while keeping URL slug "utilisation-dept"), the script flagged its own apache-*.conf as a foreign collision and refused to redeploy. Filter against \$REPO_ROOT instead, which holds the actual on-disk path and matches what grep -l emits. Co-Authored-By: Claude Opus 4.7 (1M context) --- deploy/deploy.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 6eccbe1..4d5150c 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -139,11 +139,14 @@ docker compose version >/dev/null 2>&1 || { err "docker compose v2 required"; ex VHOST=/etc/apache2/sites-enabled/optical-dev.oliver.solutions.conf if [[ -r "$VHOST" ]]; then # 1. Slug collision: is another app already claiming /utilisation-dept/? - # Look at the live vhost AND every sibling app's apache-*.conf. + # Look at the live vhost AND every sibling app's apache-*.conf, + # filtering out our OWN conf (matched on REPO_ROOT, not SLUG, since + # the on-disk path may not match the URL slug — e.g. cloned to + # /opt/loreal-utilisation-dept/ with slug "utilisation-dept"). sibling_confs=(/opt/*/deploy/apache-*.conf) collision=$(grep -lE "(ProxyPass|Alias)[[:space:]]+${URL_PATH}/" \ "$VHOST" "${sibling_confs[@]}" 2>/dev/null \ - | grep -v "/opt/${SLUG}/" || true) + | grep -vF "${REPO_ROOT}/" || true) if [[ -n "$collision" ]]; then err "Another app claims ${URL_PATH}/ in:" echo "$collision" | sed 's/^/ /' >&2