MCPcopy Create free account
hub / github.com/cli/cli / Install

Method Install

pkg/cmd/extension/manager.go:254–280  ·  view source on GitHub ↗

Install installs an extension from repo, and pins to commitish if provided

(repo ghrepo.Interface, target string)

Source from the content-addressed store, hash-verified

252
253// Install installs an extension from repo, and pins to commitish if provided
254func (m *Manager) Install(repo ghrepo.Interface, target string) error {
255 isBin, err := isBinExtension(m.client, repo)
256 if err != nil {
257 if errors.Is(err, releaseNotFoundErr) {
258 if ok, err := repoExists(m.client, repo); err != nil {
259 return err
260 } else if !ok {
261 return repositoryNotFoundErr
262 }
263 } else {
264 return fmt.Errorf("could not check for binary extension: %w", err)
265 }
266 }
267 if isBin {
268 return m.installBin(repo, target)
269 }
270
271 hs, err := hasScript(m.client, repo)
272 if err != nil {
273 return err
274 }
275 if !hs {
276 return fmt.Errorf("extension is not installable: no usable release artifact or script found in %s", ghrepo.FullName(repo))
277 }
278
279 return m.installGit(repo, target)
280}
281
282func (m *Manager) installBin(repo ghrepo.Interface, target string) error {
283 var r *release

Callers

nothing calls this directly

Calls 7

installBinMethod · 0.95
installGitMethod · 0.95
FullNameFunction · 0.92
isBinExtensionFunction · 0.85
repoExistsFunction · 0.85
hasScriptFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected