From fbf74c2736d3fd6b961fa7f87c7710fba062b093 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Mon, 23 Feb 2026 13:08:47 -0600 Subject: [PATCH] fix: strip .git suffix in repo detection (POSIX ERE non-greedy bug) POSIX ERE doesn't support non-greedy +? quantifier, so the pattern ([^/]+?)(\.git)?$ matched .git as part of the repo name instead of stripping it. Split into two sed passes: strip .git first, then extract owner/repo. Fixes wp_detect_repo() and init-project.sh CICD_REPO_NAME. Co-Authored-By: Claude Opus 4.6 --- tools/bootstrap/init-project.sh | 2 +- tools/woodpecker/_lib.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bootstrap/init-project.sh b/tools/bootstrap/init-project.sh index 76a5e22..d2c99b3 100755 --- a/tools/bootstrap/init-project.sh +++ b/tools/bootstrap/init-project.sh @@ -426,7 +426,7 @@ if [[ "$CICD_DOCKER" == true ]]; then # Extract host from https://host/org/repo.git or git@host:org/repo.git CICD_REGISTRY=$(echo "$REPO_URL" | sed -E 's|https?://([^/]+)/.*|\1|; s|git@([^:]+):.*|\1|') CICD_ORG=$(echo "$REPO_URL" | sed -E 's|https?://[^/]+/([^/]+)/.*|\1|; s|git@[^:]+:([^/]+)/.*|\1|') - CICD_REPO_NAME=$(echo "$REPO_URL" | sed -E 's|.*/([^/]+?)(\.git)?$|\1|') + CICD_REPO_NAME=$(echo "$REPO_URL" | sed -E 's|\.git$||' | sed -E 's|.*/([^/]+)$|\1|') fi if [[ -n "$CICD_REGISTRY" && -n "$CICD_ORG" && -n "$CICD_REPO_NAME" && ${#CICD_SERVICES[@]} -gt 0 ]]; then diff --git a/tools/woodpecker/_lib.sh b/tools/woodpecker/_lib.sh index fdb8a89..bb9c0e6 100644 --- a/tools/woodpecker/_lib.sh +++ b/tools/woodpecker/_lib.sh @@ -42,7 +42,7 @@ wp_detect_repo() { local remote_url remote_url=$(git remote get-url origin 2>/dev/null || true) if [[ -n "$remote_url" ]]; then - echo "$remote_url" | sed -E 's|.*[:/]([^/]+/[^/]+?)(\.git)?$|\1|' + echo "$remote_url" | sed -E 's|\.git$||' | sed -E 's|.*[:/]([^/]+/[^/]+)$|\1|' else echo "Error: -r owner/repo required (not in a git repository)" >&2 return 1