MCPcopy
hub / github.com/cli/cli / newRemoteNameToRepoFn

Function newRemoteNameToRepoFn

pkg/cmd/pr/shared/find_refs_resolution.go:228–240  ·  view source on GitHub ↗

newRemoteNameToRepoFn takes a function that returns a list of remotes and returns a function that takes a remote name and returns the corresponding repository. It is a convenience function to call sites having to duplicate the same logic.

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

Source from the content-addressed store, hash-verified

226// repository. It is a convenience function to call sites having to duplicate
227// the same logic.
228func newRemoteNameToRepoFn(remotesFn func() (ghContext.Remotes, error)) RemoteNameToRepoFn {
229 return func(remoteName string) (ghrepo.Interface, error) {
230 remotes, err := remotesFn()
231 if err != nil {
232 return nil, err
233 }
234 repo, err := remotes.FindByName(remoteName)
235 if err != nil {
236 return nil, err
237 }
238 return repo, nil
239 }
240}
241
242// remoteToRepoResolver provides a utility method to resolve a remote (either name or URL)
243// to a repo (ghrepo.Interface).

Callers 2

NewRemoteToRepoResolverFunction · 0.85

Calls 2

remotesFnFuncType · 0.85
FindByNameMethod · 0.80

Tested by

no test coverage detected