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

Function shouldCheckForUpdate

pkg/cli/update_check.go:43–71  ·  view source on GitHub ↗

shouldCheckForUpdate determines if we should check for updates based on: - CI mode (disabled) - MCP server mode (disabled via parent command detection) - Time since last check (once per day) - --no-check-update flag

(noCheckUpdate bool)

Source from the content-addressed store, hash-verified

41// - Time since last check (once per day)
42// - --no-check-update flag
43func shouldCheckForUpdate(noCheckUpdate bool) bool {
44 // Skip if explicitly disabled
45 if noCheckUpdate {
46 updateCheckLog.Print("Update check disabled via --no-check-update flag")
47 return false
48 }
49
50 // Skip in CI environments
51 if IsRunningInCI() {
52 updateCheckLog.Print("Update check disabled in CI environment")
53 return false
54 }
55
56 // Skip if running as MCP server (detected by checking if parent command is "mcp-server")
57 // When gh aw is invoked from MCP server, it's spawned as a subprocess
58 if isRunningAsMCPServer() {
59 updateCheckLog.Print("Update check disabled in MCP server mode")
60 return false
61 }
62
63 // Check if we've already checked recently
64 lastCheckFile := getLastCheckFilePath()
65 if !shouldRunUpdateCheckAtPath(lastCheckFile, checkInterval, "update check", updateCheckLog) {
66 return false
67 }
68
69 updateCheckLog.Print("Last check was more than 24 hours ago, performing check")
70 return true
71}
72
73// isRunningAsMCPServer detects if we're running as a subprocess of mcp-server
74// This is a heuristic - we can't reliably detect this, so we're conservative

Callers 2

TestShouldCheckForUpdateFunction · 0.85
checkForUpdatesFunction · 0.85

Calls 5

IsRunningInCIFunction · 0.85
isRunningAsMCPServerFunction · 0.85
getLastCheckFilePathFunction · 0.85
PrintMethod · 0.80

Tested by 1

TestShouldCheckForUpdateFunction · 0.68