MCPcopy
hub / github.com/cli/cli / BaseRepoFunc

Function BaseRepoFunc

pkg/cmd/factory/default.go:74–82  ·  view source on GitHub ↗

BaseRepoFunc requests a list of Remotes, and selects the first one. Although Remotes is injected via the factory so it looks like the function might be configurable, in practice, it's calling readRemotes, and the injection is indirection. readRemotes makes use of the remoteResolver, which is respon

(remotesFunc func() (ghContext.Remotes, error))

Source from the content-addressed store, hash-verified

72//
73// With this resolution function, the upstream will always be chosen (assuming we have authenticated with github.com).
74func BaseRepoFunc(remotesFunc func() (ghContext.Remotes, error)) func() (ghrepo.Interface, error) {
75 return func() (ghrepo.Interface, error) {
76 remotes, err := remotesFunc()
77 if err != nil {
78 return nil, err
79 }
80 return remotes[0], nil
81 }
82}
83
84// SmartBaseRepoFunc provides additional behaviour over BaseRepoFunc. Read the BaseRepoFunc
85// documentation for more information on how remotes are fetched and ordered.

Callers 3

Test_BaseRepoFunction · 0.85
Test_OverrideBaseRepoFunction · 0.85
NewFunction · 0.85

Calls 1

remotesFuncFunction · 0.85

Tested by 2

Test_BaseRepoFunction · 0.68
Test_OverrideBaseRepoFunction · 0.68