From 821a8f00c5b5f745ead6582fa4f97d433e8bf7b5 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Thu, 26 Dec 2024 22:21:10 -0500 Subject: [PATCH] macos: disable auto-updates for local (source) builds The auto-update prompt isn't useful for local (source) builds so disable both update checks and automatic downloads. There are multiple ways we could check if we've been built for source, but the easiest and least intrusive approach is to check the value of the 'GhosttyCommit' Info.plist key. Because it is only set as part of the release build process, an empty key implies that we've been build from source. --- macos/Sources/App/macOS/AppDelegate.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 7b0ff6fc2..8d56b91d5 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -485,10 +485,16 @@ class AppDelegate: NSObject, } // Sync our auto-update settings - updaterController.updater.automaticallyChecksForUpdates = - config.autoUpdate == .check || config.autoUpdate == .download - updaterController.updater.automaticallyDownloadsUpdates = - config.autoUpdate == .download + // Local (source) builds always disable the updater + if let commit = Bundle.main.infoDictionary?["GhosttyCommit"] as? String, !commit.isEmpty { + updaterController.updater.automaticallyChecksForUpdates = + config.autoUpdate == .check || config.autoUpdate == .download + updaterController.updater.automaticallyDownloadsUpdates = + config.autoUpdate == .download + } else { + updaterController.updater.automaticallyChecksForUpdates = false + updaterController.updater.automaticallyDownloadsUpdates = false + } // Config could change keybindings, so update everything that depends on that syncMenuShortcuts(config)