You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn when brew update leaves a branch unchanged - #24421
I had my brew and homebrew-core checkouts on feature branches and ran brew update. It printed Updated Homebrew from fcdfa0476e to 1f55ebf835 and Updated 2 taps (homebrew/core and homebrew/cask), so I assumed both branches had been updated. Neither had, and the brew I was running was still my branch's code on top of the old main.
This happens in developer mode, which turns itself on the first time you run a developer command. update.sh then checks out the upstream branch, rebases it onto origin/main and checks the original branch out again. The summary lines describe the upstream branch and nothing says that another branch is checked out.
update-report now prints a warning under each summary line when the upstream branch moved but HEAD isn't where it ended up. Repositories on their default branch get no warning, so the output only changes for people working on a branch. brew doctor already flags taps that aren't on their default branch, but only if you think to run it.
==> Updated Homebrew from 411ad3ef42 to 1f55ebf835.
Warning: Homebrew/brew is on branch 'update-notice-non-default-branch'
To reproduce:
brew developer on
cd "$(brew --repository)" && git switch -c my-branch origin/main~10 && git branch -f main origin/main~10
brew update reports that Homebrew was updated, but my-branch is still checked out at origin/main~10.
Have you checked for other open Pull Requests for the same change?
Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
Have you explained why you'd like these changes included, not just what they do?
For bug fixes, have you given step-by-step brew commands to reproduce the bug?
Have you written new tests (excluding integration tests)? Here's an example.
Have you successfully run brew lgtm (style, typechecking and tests) locally?
I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.
Claude Code (Claude Opus 5.5) traced how brew update restores the checked-out branch, wrote the change and its specs and verified them. The new specs fail without the change and pass with it, and removing the HEAD check makes the "does not warn" spec fail. It ran brew lgtm --online, which passes, and the output above is from a real brew update with main rewound.
The reason will be displayed to describe this comment to others. Learn more.
Good idea, unsure about implementation as-is! Would be nice to only warn if there's upstream updates and you're on a non-default branch and the warning there is just about the branch you're on as concisely as possible (1 line max)
Update reports now warn when the updated revision differs from the current branch reference in the Homebrew repository or an installed Git tap with a recorded revision. Core taps are included, even when installing from the API.
No warning is shown when the updated branch is checked out, keeping reports clear when the repository and update are in sync.
The update report checks whether updated revisions match the current branch reference. It applies this check to Homebrew and installed Git taps. Tests cover warning and no-warning cases.
Changes: Branch update warning
Layer / File(s)
Summary
Branch check and reporting Library/Homebrew/cmd/update-report.rb, Library/Homebrew/test/cmd/update-report_spec.rb
The report compares updated revisions with the current branch reference and warns when they differ. It checks Homebrew and installed Git taps. Tests cover warning and no-warning cases.
Merge Risk: Low · up to cccac
The warning works on the covered paths, but a future caller-wiring regression could leave the helper specs green while silently disabling the warning.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title states the main change: a warning is added when brew update leaves a branch unchanged. The raw summary and objectives both describe a warning shown when the upstream branch moves but HEAD do…
Description check
The description explains the problem, the cause in developer mode, the new warning behaviour, and reproduction steps. It also lists testing and checklist items. It relates directly to the changeset, s…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title states the main change: a warning is added when brew update leaves a branch unchanged. The raw summary and objectives both describe a warning shown when the upstream branch moves but HEAD does not. The title is specific and matches the changeset, so it passes.
Full details: Description check
Explanation
The description explains the problem, the cause in developer mode, the new warning behaviour, and reproduction steps. It also lists testing and checklist items. It relates directly to the changeset, so it passes.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 8e2b41e5-9aa6-47f9-a0fd-e23ca7f9a048
Commits
Reviewing files that changed from the base of the PR and between bb45d71 and 5c351b9.
Files selected for processing: 2
Library/Homebrew/cmd/update-report.rb
Library/Homebrew/test/cmd/update-report_spec.rb
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
- In developer mode, `brew update` rebases the upstream branch and then
checks out the original branch again, which it leaves untouched.
- The only output was `Updated Homebrew from X to Y`, which describes
the upstream branch, so it looked like the checked-out branch, and
the `brew` code running from it, had been updated too.
- Warn under that line and under `Updated N taps` for each repository
with another branch checked out. Repositories on their default branch
get no warning, so the output only changes when working on a branch.
The reason will be displayed to describe this comment to others. Learn more.
Follow-up Comments
Keep installed Git tap warnings reachable when formula loading is disabled
296-298: Minor · Functional Correctness · Quick win
Keep installed Git tap warnings reachable when formula loading is disabled
When HOMEBREW_DISABLE_LOAD_FORMULA=1, brew update still updates Git taps, records their revisions, and runs brew update-report. The return at line 242 prevents the installed Git tap loop from running. Therefore, update-report omits the warning when an updated tap remains on its original branch.
Move this independent loop before the early return, or restructure the return so that it skips only formula-dependent reporting.
Suggested fix
migrate_caskroom_caskfiles_to_json
+ Tap.installed.select(&:git?).each do |tap|+ warn_if_branch_not_updated(tap.name, tap.git_repository, tap.repository_var_suffix)+ end+
return if Homebrew::EnvConfig.disable_load_formula?
@@
- Tap.installed.select(&:git?).each do |tap|- warn_if_branch_not_updated(tap.name, tap.git_repository, tap.repository_var_suffix)- end-
if updated
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: efd82075-fff2-452b-b42e-fb20440a3656
Commits
Reviewing files that changed from the base of the PR and between 5c351b9 and f3acb38.
Files selected for processing: 1
Library/Homebrew/cmd/update-report.rb
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Add a report-level example for the branch-warning call sites.
The new specs call warn_if_branch_not_updated directly and pass tap.git_head. They do not run UpdateReport#run. No spec therefore covers the call at update-report.rb:232 that passes HOMEBREW_UPDATE_AFTER, or the call at update-report.rb:313 that passes the suffixed tap revision. A removed call, or one that reads the wrong variable, would leave these specs passing.
The tap call sits after return if Homebrew::EnvConfig.disable_load_formula?. A report-level example must therefore leave that flag unset. It should set HOMEBREW_UPDATE_BEFORE<suffix> and HOMEBREW_UPDATE_AFTER<suffix> to different values while the tap has a non-updated branch checked out. It should then expect the warning on stderr. Stub the steps before the loop that the example does not need, as the existing report-level examples do.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 9a79b706-1cc8-4e12-92f4-b0a0a65e60bd
Commits
Reviewing files that changed from the base of the PR and between 80d3e41 and cccac41.
Files selected for processing: 2
Library/Homebrew/cmd/update-report.rb
Library/Homebrew/test/cmd/update-report_spec.rb
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
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
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.
I had my brew and homebrew-core checkouts on feature branches and ran
brew update. It printedUpdated Homebrew from fcdfa0476e to 1f55ebf835andUpdated 2 taps (homebrew/core and homebrew/cask), so I assumed both branches had been updated. Neither had, and thebrewI was running was still my branch's code on top of the oldmain.This happens in developer mode, which turns itself on the first time you run a developer command.
update.shthen checks out the upstream branch, rebases it ontoorigin/mainand checks the original branch out again. The summary lines describe the upstream branch and nothing says that another branch is checked out.update-reportnow prints a warning under each summary line when the upstream branch moved butHEADisn't where it ended up. Repositories on their default branch get no warning, so the output only changes for people working on a branch.brew doctoralready flags taps that aren't on their default branch, but only if you think to run it.To reproduce:
brew developer oncd "$(brew --repository)" && git switch -c my-branch origin/main~10 && git branch -f main origin/main~10brew updatereports that Homebrew was updated, butmy-branchis still checked out atorigin/main~10.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Claude Opus 5.5) traced how
brew updaterestores the checked-out branch, wrote the change and its specs and verified them. The new specs fail without the change and pass with it, and removing theHEADcheck makes the "does not warn" spec fail. It ranbrew lgtm --online, which passes, and the output above is from a realbrew updatewithmainrewound.