Skip to content
Open
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
6 changes: 4 additions & 2 deletions src/ghstack/github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def get_github_repo_name_with_owner(
remote_name: str,
) -> GitHubRepoNameWithOwner:
# Grovel in remotes to figure it out
remote_url = sh.git("remote", "get-url", remote_name)
# Use --push to get the push URL, which is what matters for determining
# where commits will actually be pushed to
remote_url = sh.git("remote", "get-url", "--push", remote_name)
while True:
match = r"^git@{github_url}:/?([^/]+)/(.+?)(?:\.git)?$".format(
github_url=github_url
Expand Down Expand Up @@ -158,7 +160,7 @@ def parse_pull_request(
if not m:
# We can reconstruct the URL if just a PR number is passed
if sh is not None and remote_name is not None:
remote_url = sh.git("remote", "get-url", remote_name)
remote_url = sh.git("remote", "get-url", "--push", remote_name)
# Do not pass the shell to avoid infinite loop
try:
return parse_pull_request(
Expand Down