MCPcopy
hub / github.com/cli/cli / LatestVersion

Method LatestVersion

pkg/cmd/extension/extension.go:116–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114}
115
116func (e *Extension) LatestVersion() string {
117 e.mu.RLock()
118 if e.latestVersion != "" {
119 defer e.mu.RUnlock()
120 return e.latestVersion
121 }
122 e.mu.RUnlock()
123
124 var latestVersion string
125 switch e.kind {
126 case LocalKind:
127 case BinaryKind:
128 repo, err := ghrepo.FromFullName(e.URL())
129 if err != nil {
130 return ""
131 }
132 release, err := fetchLatestRelease(e.httpClient, repo)
133 if err != nil {
134 return ""
135 }
136 latestVersion = release.Tag
137 case GitKind:
138 if lsRemote, err := e.gitClient.CommandOutput([]string{"ls-remote", "origin", "HEAD"}); err == nil {
139 latestVersion = string(bytes.SplitN(lsRemote, []byte("\t"), 2)[0])
140 }
141 }
142
143 e.mu.Lock()
144 e.latestVersion = latestVersion
145 e.mu.Unlock()
146
147 return e.latestVersion
148}
149
150func (e *Extension) IsPinned() bool {
151 e.mu.RLock()

Callers 1

UpdateAvailableMethod · 0.95

Calls 4

URLMethod · 0.95
FromFullNameFunction · 0.92
fetchLatestReleaseFunction · 0.85
CommandOutputMethod · 0.65

Tested by

no test coverage detected