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.
This commit is contained in:
Mislav Marohnić 2020-07-16 18:54:35 +02:00
parent 89adc83194
commit f93261a6f9

View file

@ -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