From f93261a6f9413c88fd43de88ddf8646805a99196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 16 Jul 2020 18:54:35 +0200 Subject: [PATCH] Revert to ignoring non-github.com git remotes This fixes a regression where extra git remotes pointing to non-github.com hostnames could result in gh trying to parse repository information from them. --- context/context.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/context/context.go b/context/context.go index 74253e1d2..e83e0b44e 100644 --- a/context/context.go +++ b/context/context.go @@ -240,10 +240,22 @@ func (c *fsContext) Remotes() (Remotes, error) { } sshTranslate := git.ParseSSHConfig().Translator() - c.remotes = translateRemotes(gitRemotes, sshTranslate) + resolvedRemotes := translateRemotes(gitRemotes, sshTranslate) + + // ignore non-github.com remotes + // TODO: GHE compatibility + filteredRemotes := Remotes{} + for _, r := range resolvedRemotes { + if r.RepoHost() != defaultHostname { + continue + } + filteredRemotes = append(filteredRemotes, r) + } + c.remotes = filteredRemotes } if len(c.remotes) == 0 { + // TODO: GHE compatibility return nil, errors.New("no git remote found for a github.com repository") } return c.remotes, nil