diff options
author | Christian Muehlhaeuser <muesli@gmail.com> | 2022-02-01 07:48:59 +0100 |
---|---|---|
committer | Christian Muehlhaeuser <muesli@gmail.com> | 2022-02-01 08:11:13 +0100 |
commit | 917b628ee717d25e7be9c7db7f315fd9aa176c11 (patch) | |
tree | d71cdc4958fdaccc81538fe76ff86c364fc2c8f2 | |
parent | aa70c7a02c998da3ae1bda20943bdde04ec9e7d3 (diff) |
Prioritize upstream remote over origin
Fixes #28.
-rw-r--r-- | git.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -16,6 +16,11 @@ import ( "github.com/muesli/gitty/vcs/gitlab" ) +const ( + originRemote = "origin" + upstreamRemote = "upstream" +) + // Client defines the set of methods required from a git provider. type Client interface { Issues(owner string, name string) ([]vcs.Issue, error) @@ -114,11 +119,15 @@ func remoteURL(path string) (string, string, error) { var u string var rn string for _, v := range remotes { - if (v.Config().Name == "origin" && rn != "origin") || + if (v.Config().Name == upstreamRemote && rn != upstreamRemote) || rn == "" { rn = v.Config().Name u = v.Config().URLs[0] } + if v.Config().Name == originRemote && rn != originRemote && rn != upstreamRemote { + rn = v.Config().Name + u = v.Config().URLs[0] + } } if u == "" { |