Parse and store both fetch and push URLs from git remotes.
It is a common practice to set the push URL of the "upstream" repository to an invalid URL to avoid accidentally pushing to upstream instead of a fork. The trouble with the current approach of obtaining remote URLs is that, the URL obtained for a remote might not be the valid one, even though a valid remote fetch URL exists. For example, git remote -v might return the following output ~$ git remote -v origin https://github.com/owner/project.git (fetch) origin https://github.com/owner/project.git (push) upstream https://github.com/main/project.git (fetch) upstream no_push (push) But github.Remotes() currently parses both these URLs but stores only one of them, the one that comes the last in git remote -v output, for a given remote. So in this example, the URL for upstream remote might end up to be "no_push" instead of https://github.com/main/project.git. This causes problems downstream. For example, pull-request can't proceed with non github.com URLs and the command fails even when a valid fetch URL for upstream is defined. This commit fixes the problem by parsing and storing both fetch and push URLs for each remote. So later, wherever the URLs are required, we can either look at fetch URL or push URL or both depending on what is required. Fixes one part of issue #876. Still doesn't recognize "git+ssh" protocol scheme.
Showing
想要评论请 注册 或 登录