Auto-update brew before the outdated check - #250
dergachoff wants to merge 2 commits into
Conversation
`brew info` never triggers Homebrew's auto-update. With the API on it re-downloads API data only once the cache is 7 days old, so the Upgrades tab showed what the last terminal `brew update` saw. Run `brew outdated --quiet` before `brew info` instead of `brew update` under HOMEBREW_NO_INSTALL_FROM_API only. `outdated` is an auto-update command, so Homebrew applies HOMEBREW_NO_AUTO_UPDATE, its own update interval and API refresh interval, in both API and tap modes. The `brew config` probe that chose between the modes is no longer needed. Fixes Homebrew#235
There was a problem hiding this comment.
Copilot review overview
馃數 Needs a closer look
Existing installed-package test doubles must support the new outdated --quiet invocation, and the fallback should validate exact command arguments.
Review effort: Lite
Findings: None
What changed in this PR
Updates installed-package refreshes to run brew outdated --quiet before fetching brew info, allowing Homebrew to manage auto-update timing.
Changes:
- Replaces conditional updates with auto-update-aware
brew outdated --quiet. - Removes obsolete
brew configenvironment detection. - Updates repository wiring, command doubles, and refresh tests.
| File | Summary |
|---|---|
Tests/鈥婤rewRepositoriesTests/鈥婤rewInstalledPackagesTapRefreshTests.swift |
Tests refresh ordering and throttling; command fallback should reject unexpected arguments. |
Tests/鈥婤rewRepositoriesTests/鈥婤rewInstalledPackagesRepositoryTests.swift |
Updates repository test coverage and command runners. |
Tests/鈥婤rewCLITests/鈥婤rewConfigEnvironmentReaderTests.swift |
Removes obsolete reader tests. |
Sources/鈥婤rewServicesTestSupport/鈥婭nstalledPackagesTestSupport.swift |
Simplifies repository test wiring. |
Sources/鈥婤rewServicesTestSupport/鈥婥ommandRunnerDoubles.swift |
Updates command doubles for installed-package queries. |
Sources/鈥婤rewRepositories/鈥婤rewInstalledPackagesRepository.swift |
Runs brew outdated --quiet before fetching installed package information. |
Sources/鈥婤rewCore/鈥婳perations/鈥婬omebrewEnvironmentReading.swift |
Removes the obsolete environment-reading protocol. |
Sources/鈥婤rewCLI/鈥婥onfig/鈥婤rewConfigEnvironmentReader.swift |
Removes the obsolete configuration reader. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Why run |
|
This runs on its own, on app launch and after every install. So I kept brew's auto-update rules: calling |
|
But for intentional button press it won't work for those with "no auto" flags. Makes sense to split into outdated for background and update for hotkey/button. On it 馃 |
|
Pushed 2b19184. Refresh, Try Again and 鈱楻 now run |
Makes no sense to run |
What and why
Problem: the Upgrades tab does not show new upgrades until you run
brew updatein a terminal. Refresh does not help.Root cause: the list comes from
brew info --installed --json=v2.brew infodoes not trigger Homebrew's auto-update.DEFAULT_API_STALE_SECONDSinLibrary/Homebrew/api.rb).brew updatestep (dd9452a) only runs whenHOMEBREW_NO_INSTALL_FROM_APIis set.Fix: run
brew outdated --quietbeforebrew info.outdatedis an auto-update command, so Homebrew itself decides when to update.HOMEBREW_NO_AUTO_UPDATEandHOMEBREW_AUTO_UPDATE_SECS, and refreshes API data after 450s. This works in both API and tap modes.brew update --auto-updatedirectly skips those checks, so I replaced it.brew configcheck is no longer needed, so I removed it.brew infonow answer onlyinfocalls.brew updateinstead, since the user asked for it.Fixes #235
Validation
scripts/test: pass (also passes on base a9920b4)--strict, BrewUILint,scripts/localize verify: cleanxcodebuild test -scheme Brew-Unitwith CI flags: passupdate; launch, stale cache and the refresh after installs run throttledoutdated.HOMEBREW_NO_AUTO_UPDATE=1: cache stays old (setting respected)scripts/test-ui. The runner was killed before connecting under local ad-hoc signing.macOS 27.0, Apple silicon, Xcode 27.0 (27A5194q), Swift 6.4.
Screenshots
Not applicable. The UI does not change, only how fresh the data behind the list is.
AI assistance
Claude Code (Claude Opus 5.5) found the cause, wrote the patch and ran the checks above. Codex (gpt-6-astra) reviewed it. I reported the bug in #235 and reviewed the diff.