From cd8b7f7920f9ccacaeb4cf79fd13d49c7ece8034 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 21 Mar 2026 09:55:53 -0700 Subject: [PATCH] fix: gstack-repo-mode handles repos without origin remote Split `git remote get-url origin` into a separate variable with `|| true` so the script doesn't crash under `set -euo pipefail` in local-only repos. Falls back to REPO_MODE=unknown gracefully. Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/gstack-repo-mode | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/gstack-repo-mode b/bin/gstack-repo-mode index 0c9ce904..563f6a16 100755 --- a/bin/gstack-repo-mode +++ b/bin/gstack-repo-mode @@ -13,7 +13,12 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" # Compute SLUG directly (avoid eval of gstack-slug — branch names can contain shell metacharacters) -SLUG=$(git remote get-url origin 2>/dev/null | sed 's|.*[:/]\([^/]*/[^/]*\)\.git$|\1|;s|.*[:/]\([^/]*/[^/]*\)$|\1|' | tr '/' '-') +REMOTE_URL=$(git remote get-url origin 2>/dev/null || true) +if [ -z "$REMOTE_URL" ]; then + echo "REPO_MODE=unknown" + exit 0 +fi +SLUG=$(echo "$REMOTE_URL" | sed 's|.*[:/]\([^/]*/[^/]*\)\.git$|\1|;s|.*[:/]\([^/]*/[^/]*\)$|\1|' | tr '/' '-') [ -z "${SLUG:-}" ] && { echo "REPO_MODE=unknown"; exit 0; } # Validate: only allow known values (prevent shell injection via source <(...))