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

Function runCompileUpdateCheck

pkg/cli/compile_update_check.go:165–210  ·  view source on GitHub ↗
(ctx context.Context, client *http.Client)

Source from the content-addressed store, hash-verified

163}
164
165func runCompileUpdateCheck(ctx context.Context, client *http.Client) (*compileUpdateNotification, error) {
166 currentVersion := GetVersion()
167 if !workflow.IsReleasedVersion(currentVersion) {
168 compileUpdateCheckLog.Print("Not a released version, skipping update check")
169 return nil, nil
170 }
171
172 latestVersion, err := fetchLatestReleaseTag(ctx, client)
173 if err != nil {
174 return nil, err
175 }
176 if latestVersion == "" {
177 return nil, nil
178 }
179
180 latestTagExists, err := downloadReleaseProbeFile(ctx, client, latestVersion)
181 if err != nil {
182 return nil, err
183 }
184 if !latestTagExists {
185 compileUpdateCheckLog.Printf("Latest release tag %s did not expose the probe file; skipping", latestVersion)
186 return nil, nil
187 }
188
189 currentTagExists, err := downloadReleaseProbeFile(ctx, client, currentVersion)
190 if err != nil {
191 return nil, err
192 }
193 if !currentTagExists {
194 return &compileUpdateNotification{
195 Kind: compileUpdateNotificationRemovedTag,
196 CurrentVersion: currentVersion,
197 LatestVersion: latestVersion,
198 }, nil
199 }
200
201 if !isMinorVersionBehind(currentVersion, latestVersion) {
202 return nil, nil
203 }
204
205 return &compileUpdateNotification{
206 Kind: compileUpdateNotificationMinorBehind,
207 CurrentVersion: currentVersion,
208 LatestVersion: latestVersion,
209 }, nil
210}
211
212func fetchLatestReleaseTag(ctx context.Context, client *http.Client) (string, error) {
213 req, err := http.NewRequestWithContext(ctx, http.MethodHead, compileUpdateCheckLatestReleaseURL, nil)

Calls 7

IsReleasedVersionFunction · 0.92
fetchLatestReleaseTagFunction · 0.85
downloadReleaseProbeFileFunction · 0.85
isMinorVersionBehindFunction · 0.85
PrintMethod · 0.80
GetVersionFunction · 0.70
PrintfMethod · 0.45