Skip to content

Commit f93261a

Browse files
committed
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.
1 parent 89adc83 commit f93261a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

context/context.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,22 @@ func (c *fsContext) Remotes() (Remotes, error) {
240240
}
241241

242242
sshTranslate := git.ParseSSHConfig().Translator()
243-
c.remotes = translateRemotes(gitRemotes, sshTranslate)
243+
resolvedRemotes := translateRemotes(gitRemotes, sshTranslate)
244+
245+
// ignore non-github.com remotes
246+
// TODO: GHE compatibility
247+
filteredRemotes := Remotes{}
248+
for _, r := range resolvedRemotes {
249+
if r.RepoHost() != defaultHostname {
250+
continue
251+
}
252+
filteredRemotes = append(filteredRemotes, r)
253+
}
254+
c.remotes = filteredRemotes
244255
}
245256

246257
if len(c.remotes) == 0 {
258+
// TODO: GHE compatibility
247259
return nil, errors.New("no git remote found for a github.com repository")
248260
}
249261
return c.remotes, nil

0 commit comments

Comments
 (0)