Repository navigation
fix(skills): resolve's repo-detection fallback regex retains .git suffix - #2362
Merged
Merged
Conversation
Closes #2186 Greptile caught the identical flaw in PR #2185 while reviewing the same fallback pattern being added to /sweep. /resolve had it in two places (gh repo view's fallback when gh isn't authenticated): REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') 1. The greedy (.+) capture swallows .git before the optional (\.git)? group ever matches it, so a standard https://.../repo.git or git@github.com:owner/repo.git remote resolves to "owner/repo.git" instead of "owner/repo" — every subsequent gh --repo call then targets an invalid slug. 2. When origin isn't a github.com URL at all, plain `sed 's|pattern| replacement|'` leaves a non-matching line unchanged, so the raw (wrong) URL becomes $REPO — non-empty, so the existing `-z` guard doesn't catch it, and the skill proceeds with a garbage repo identifier instead of failing loudly. Mirrors the exact fix already applied to /sweep in PR #2185: a two-pass sed (non-greedy quantifiers aren't POSIX ERE — `+?` errors on BSD sed's -E and isn't GNU-portable either). The first pass only prints when the URL is a genuine github.com remote (so a non-GitHub origin correctly produces empty output, caught by the -z guard); the second unconditionally strips a trailing .git, sidestepping the greedy-capture problem entirely.
Contributor
Greptile SummaryThe fallback repository detection now accepts both SCP-style and
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix(skills): resolve fallback regex also..." | Re-trigger Greptile |
| || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') | ||
| || git remote get-url origin 2>/dev/null \ | ||
| | sed -nE 's#^(git@github\.com:|https://github\.com/)([^/]+/[^/]+)/?$#\2#p' \ | ||
| | sed -E 's/\.git$//') |
Contributor
Greptile flagged (PR #2362) that the anchored two-pass sed only accepted git@github.com:owner/repo and https://github.com/owner/repo, silently rejecting ssh://git@github.com/owner/repo — a valid GitHub remote URL form the OLD (buggy) regex happened to accept via its permissive prefix match. A genuine regression, not a pre-existing gap. Added it as a third alternative in the prefix group. Filed #2363 for the identical gap in /sweep's PR #2185, the original source of this fallback pattern — out of scope for this PR.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2186
Greptile caught the identical flaw in PR #2185 while reviewing the same fallback pattern being added to
/sweep./resolvehad it in two places (gh repo view's fallback, only exercised whenghisn't authenticated):(.+)capture swallows.gitbefore the optional(\.git)?group ever gets a chance to match it, so a standardhttps://github.com/owner/repo.gitorgit@github.com:owner/repo.gitremote resolves toowner/repo.gitinstead ofowner/repo— every subsequentgh --repocall in the skill then targets an invalid slug.originisn't agithub.comURL at all, plainsed 's|pattern|replacement|'leaves a non-matching line unchanged, so the raw (wrong) URL becomes$REPO— non-empty, so the existing-zguard doesn't catch it, and the skill proceeds with a garbage repo identifier instead of failing loudly.Fix
Mirrors the exact fix already applied to
/sweepin PR #2185: a two-passsed(non-greedy quantifiers aren't POSIX ERE —+?errors on BSD sed's-Eand isn't GNU-portable either). The first pass only prints when the URL is a genuinegithub.comremote (so a non-GitHuborigincorrectly produces empty output, caught by the-zguard); the second unconditionally strips a trailing.git, sidestepping the greedy-capture problem entirely.Test plan
https://github.com/owner/repo.git,git@github.com:owner/repo.git,https://github.com/owner/repo(no suffix), and a non-GitHub remote (https://gitlab.com/owner/repo.git) — all four resolve correctly (owner/repo,owner/repo,owner/repo, empty respectively)..claude/skills/create-skill/scripts/lint-skill.shagainst this file: same pre-existing errors, plus the same2>/dev/null-without-comment warning already present (and unaddressed) on the identical construct in/sweep's already-merged version — no new issue class introduced.