MCPcopy Create free account
hub / github.com/github/gh-aw / isCurrentVersionAtLeastLatest

Function isCurrentVersionAtLeastLatest

pkg/cli/update_check.go:162–181  ·  view source on GitHub ↗
(currentVersion, latestVersion string)

Source from the content-addressed store, hash-verified

160}
161
162func isCurrentVersionAtLeastLatest(currentVersion, latestVersion string) bool {
163 if latestVersion == currentVersion {
164 return true
165 }
166
167 currentVersionNormalized := strings.TrimPrefix(currentVersion, "v")
168 latestVersionNormalized := strings.TrimPrefix(latestVersion, "v")
169
170 if currentVersionNormalized == latestVersionNormalized {
171 return true
172 }
173
174 currentSV := semverutil.EnsureVPrefix(currentVersion)
175 latestSV := semverutil.EnsureVPrefix(latestVersion)
176 if semverutil.IsValid(currentSV) && semverutil.IsValid(latestSV) {
177 return semverutil.Compare(currentSV, latestSV) >= 0
178 }
179
180 return currentVersionNormalized > latestVersionNormalized
181}
182
183// getLatestRelease queries GitHub API for the latest release of gh-aw
184func getLatestRelease(includePrereleases bool) (string, error) {

Callers 2

checkForUpdatesFunction · 0.85

Calls 3

EnsureVPrefixFunction · 0.92
IsValidFunction · 0.92
CompareFunction · 0.92

Tested by 1