Skip to content

Commit

Permalink
(feat): allow sl pr submit to support organization-specific GitHub UR…
Browse files Browse the repository at this point in the history
…Ls (#1021)

Summary:
Example usage:
`ssh://[email protected]/bolinfest/escoria-demo-game.git` set as the default URL will work now because of an updated regex pattern. Updated docstring and test for this function.

Pull Request resolved: #1021

Reviewed By: quark-zju

Differential Revision: D68876945

fbshipit-source-id: 7cfe9b912d8206e80101c308902cd4b7c347bd5b
  • Loading branch information
vincent-4 authored and facebook-github-bot committed Jan 31, 2025
1 parent c618f95 commit 44bea27
Showing 1 changed file with 4 additions and 1 deletion.
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
Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit 44bea27

Please sign in to comment.