summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2022-02-01 07:48:59 +0100
committerChristian Muehlhaeuser <muesli@gmail.com>2022-02-01 08:11:13 +0100
commit917b628ee717d25e7be9c7db7f315fd9aa176c11 (patch)
treed71cdc4958fdaccc81538fe76ff86c364fc2c8f2
parentaa70c7a02c998da3ae1bda20943bdde04ec9e7d3 (diff)
Prioritize upstream remote over origin
Fixes #28.
-rw-r--r--git.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/git.go b/git.go
index 8191673..8550830 100644
--- a/git.go
+++ b/git.go
@@ -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 == "" {