From 316b902374bbe98381000d0a4e61c7eb0ede981d Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 9 Apr 2024 09:04:24 -0400 Subject: [PATCH] Update [ghstack-poisoned] --- ghstack/github_utils.py | 2 +- test/github_utils/get_repo_name_with_owner.py.test | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ghstack/github_utils.py b/ghstack/github_utils.py index d055132..f8000ac 100644 --- a/ghstack/github_utils.py +++ b/ghstack/github_utils.py @@ -27,7 +27,7 @@ def get_github_repo_name_with_owner( # Grovel in remotes to figure it out remote_url = sh.git("remote", "get-url", remote_name) while True: - match = r"^git@{github_url}:([^/]+)/(.+?)(?:\.git)?$".format( + match = r"^git@{github_url}:/?([^/]+)/(.+?)(?:\.git)?$".format( github_url=github_url ) m = re.match(match, remote_url) diff --git a/test/github_utils/get_repo_name_with_owner.py.test b/test/github_utils/get_repo_name_with_owner.py.test index 93a6ed0..9f5e3ef 100644 --- a/test/github_utils/get_repo_name_with_owner.py.test +++ b/test/github_utils/get_repo_name_with_owner.py.test @@ -63,3 +63,10 @@ assert_eq( ), {"owner": "ezyang", "name": "ghstack.dotted"}, ) +git("remote", "add", "with-leading-slash", "git@github.com:/ezyang/ghstack.git") +assert_eq( + ghstack.github_utils.get_github_repo_name_with_owner( + sh=sh, github_url="github.com", remote_name="with-leading-slash" + ), + {"owner": "ezyang", "name": "ghstack"}, +)