Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat): allow sl pr submit to support organization-specific GitHub URLs #1021

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
(feat): allow sl pr submit with the default path set to ssh://org-123…
[email protected]/foo/bar.git

- updated regex pattern in
`eden/scm/sapling/ext/github/github_repo_util.py`
- has the same structure validation
- added docstring validation
vincent-4 committed Jan 30, 2025

Verified

This commit was signed with the committer’s verified signature.
vincent-4 Vincent
commit c978b23432208eb6305f4a10b88284338c5cbfe6
5 changes: 4 additions & 1 deletion eden/scm/sapling/ext/github/github_repo_util.py
Original file line number Diff line number Diff line change
@@ -174,6 +174,7 @@ def parse_github_repo_from_github_url(url: str) -> Optional[GitHubRepo]:
[email protected]:bolinfest/escoria-demo-game.git
git+ssh://[email protected]:bolinfest/escoria-demo-game.git
ssh://[email protected]/bolinfest/escoria-demo-game.git
ssh://[email protected]/bolinfest/escoria-demo-game.git
and returns:
@@ -197,8 +198,10 @@ def parse_github_repo_from_github_url(url: str) -> Optional[GitHubRepo]:
'https://foo.bar.com/bolinfest/escoria-demo-game'
>>> parse_github_repo_from_github_url("git+ssh://[email protected]:bolinfest/escoria-demo-game.git").to_url()
'https://foo.bar.com/bolinfest/escoria-demo-game'
>>> parse_github_repo_from_github_url("ssh://[email protected]/bolinfest/escoria-demo-game.git").to_url()
'https://github.com/bolinfest/escoria-demo-game'
"""
pattern = r"(?:https://([^/]+)|(?:git\+ssh://|ssh://)?git@([^:/]+))[:/]([^/]+)\/(.+?)(?:\.git)?$"
pattern = r"(?:https://([^/]+)|(?:git\+ssh://|ssh://)?[^@]+@([^:/]+))[:/]([^/]+)\/(.+?)(?:\.git)?$"
match = re.match(pattern, url)
if match:
hostname1, hostname2, owner, repo = match.groups()