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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user