Skip to content

Commit 5510cb6

Browse files
authored
Handle leading slash in SSH url (#245)
Fixes #244 Signed-off-by: Edward Z. Yang <[email protected]>
1 parent 0c412bf commit 5510cb6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

ghstack/github_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_github_repo_name_with_owner(
2727
# Grovel in remotes to figure it out
2828
remote_url = sh.git("remote", "get-url", remote_name)
2929
while True:
30-
match = r"^git@{github_url}:([^/]+)/(.+?)(?:\.git)?$".format(
30+
match = r"^git@{github_url}:/?([^/]+)/(.+?)(?:\.git)?$".format(
3131
github_url=github_url
3232
)
3333
m = re.match(match, remote_url)

test/github_utils/get_repo_name_with_owner.py.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ assert_eq(
6363
),
6464
{"owner": "ezyang", "name": "ghstack.dotted"},
6565
)
66+
git("remote", "add", "with-leading-slash", "[email protected]:/ezyang/ghstack.git")
67+
assert_eq(
68+
ghstack.github_utils.get_github_repo_name_with_owner(
69+
sh=sh, github_url="github.com", remote_name="with-leading-slash"
70+
),
71+
{"owner": "ezyang", "name": "ghstack"},
72+
)

0 commit comments

Comments
 (0)