Skip to content

Commit

Permalink
Prioritize upstream remote over origin
Browse files Browse the repository at this point in the history
Fixes #28.
  • Loading branch information
muesli committed Feb 1, 2022
1 parent aa70c7a commit 917b628
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 == "" {
Expand Down

0 comments on commit 917b628

Please sign in to comment.