Repository navigation
Read the linked keg version, not the oldest keg - #24
Open
alexmikheen wants to merge 1 commit into
Open
alexmikheen wants to merge 1 commit into
alexmikheen wants to merge 1 commit into
Conversation
brew info sorts "installed" from oldest to newest, so installed[0] is the oldest keg. With an old keg left on disk, check --min-version compared the wrong version and asked for an upgrade that was not needed. check now uses the version in use: - linked_keg, when it is a stable keg that brew lists as installed; - otherwise (a keg-only formula, a linked HEAD keg, or a link to a keg that is gone) the newest installed stable keg. A HEAD keg is used only when no stable keg exists, because a HEAD version cannot be compared. Older kegs left on disk are no longer checked; the README says so. The version field in check's JSON output and the exported InstalledVersion / VersionMeetsOrExceedsMinimum follow the same rule. HomebrewFormula gets a LinkedKeg field, and a test pins that the cached path keeps it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getVersionreturnedinstalled[0]. Homebrew sortsinstalledfrom oldest to newest (installed_kegs.sort_by(&:scheme_and_version)inFormula#to_hash), so with an old keg still on diskcheck --min-versioncompared the oldest version, not the one in use.Example: git 2.45.0 and 2.52.0 kegs, 2.52.0 linked.
check --min-version=2.50 gitsaid "below minimum" and Munki ran an upgrade that was not needed. An old keg stays when cleanup is turned off (HOMEBREW_NO_INSTALL_CLEANUP, or the formula is listed inHOMEBREW_NO_CLEANUP_FORMULAE).Changes
HomebrewFormulagetsLinkedKeg(linked_keg). The cache already stores the fullbrew infooutput, and a test pins that the cached path keeps the field.checkuses the version in use:linked_kegwhen it is a stable keg that brew lists as installed; otherwise (a keg-only formula, a linkedHEAD-…keg, or a link to a keg that is gone) the newest installed stable keg. A HEAD keg is used only when no stable keg exists, because a HEAD version cannot be compared.## Check): states that the version in use is checked and that older kegs left on disk are not.Behaviour changes to be aware of
mainan old keg below the floor madecheckfail, and the pairedcarafe upgraderanbrew cleanup <formula>, which removed it. If you want old kegs gone,brew cleanupstill does that.versionfield incheck's JSON output, and the exportedInstalledVersion/VersionMeetsOrExceedsMinimum, follow the same rule.HomebrewFormula{...}literals, if anyone uses them.Tests
TestGetVersion: old keg plus newer linked keg; keg-only formula with two kegs; keg-only with stable and HEAD kegs; linked HEAD keg next to a stable keg; linked keg missing frominstalled; only a HEAD keg.TestInfoOutputCached_KeepsLinkedKeg.linked_kegmatched aninstalledentry for all 118 linked formulae, including versions with a revision (4.0.0_2).go test ./...,-race,golangci-lint run(v2.6.2) and the coverage check pass. Coverage: 79.5% onmain, 79.8% with this PR.Independent of the other two PRs; all three merge together cleanly, and the merged tree passes the same checks (82.0% coverage).