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

Function getExtensions

pkg/cmd/extension/browse/browse.go:62–109  ·  view source on GitHub ↗
(opts ExtBrowseOpts)

Source from the content-addressed store, hash-verified

60}
61
62func getExtensions(opts ExtBrowseOpts) ([]extEntry, error) {
63 extEntries := []extEntry{}
64
65 installed := opts.Em.List()
66
67 result, err := opts.Searcher.Repositories(search.Query{
68 Kind: search.KindRepositories,
69 Limit: 1000,
70 Qualifiers: search.Qualifiers{
71 Topic: []string{"gh-extension"},
72 },
73 })
74 if err != nil {
75 return extEntries, fmt.Errorf("failed to search for extensions: %w", err)
76 }
77
78 host, _ := opts.Cfg.Authentication().DefaultHost()
79
80 for _, repo := range result.Items {
81 if !strings.HasPrefix(repo.Name, "gh-") {
82 continue
83 }
84 ee := extEntry{
85 URL: "https://" + host + "/" + repo.FullName,
86 FullName: repo.FullName,
87 Name: repo.Name,
88 description: repo.Description,
89 }
90 for _, installedExtension := range installed {
91 var installedRepo string
92 if u, err := git.ParseURL(installedExtension.URL()); err == nil {
93 if r, err := ghrepo.FromURL(u); err == nil {
94 installedRepo = ghrepo.FullName(r)
95 }
96 }
97 if repo.FullName == installedRepo {
98 ee.Installed = true
99 }
100 }
101 if repo.Owner.Login == "cli" || repo.Owner.Login == "github" {
102 ee.Official = true
103 }
104
105 extEntries = append(extEntries, ee)
106 }
107
108 return extEntries, nil
109}
110
111func ExtBrowse(opts ExtBrowseOpts) error {
112 if opts.Debug {

Callers 2

ExtBrowseFunction · 0.85

Calls 9

ParseURLFunction · 0.92
FromURLFunction · 0.92
FullNameFunction · 0.92
ListMethod · 0.65
RepositoriesMethod · 0.65
ErrorfMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65
URLMethod · 0.65