Skip to content

Warn when brew update leaves a branch unchanged - #24421

Merged
MikeMcQuaid merged 7 commits into
mainfrom
update-notice-non-default-branch
Nov 1, 2026
Merged

MikeMcQuaid merged 7 commits into
mainfrom
update-notice-non-default-branch

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

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:

  1. brew developer on
  2. cd "$(brew --repository)" && git switch -c my-branch origin/main~10 && git branch -f main origin/main~10
  3. brew update reports that Homebrew was updated, but my-branch is still checked out at origin/main~10.

  • Have you followed our Contributing guidelines?
  • 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.


@HaraldNordgren
HaraldNordgren force-pushed the update-notice-non-default-branch branch from 8962b48 to 9acb0c3 Compare November 1, 2026 13:42

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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)

Comment thread Library/Homebrew/cmd/update-report.rb Resolved
@HaraldNordgren
HaraldNordgren force-pushed the update-notice-non-default-branch branch from 64a0f96 to 5c351b9 Compare November 1, 2026 14:43
@HaraldNordgren
HaraldNordgren marked this pull request as ready for review November 1, 2026 14:44
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Summary

Summary by CodeRabbit

  • Bug Fixes
    • 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: Passed 4
Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

Comment thread Library/Homebrew/cmd/update-report.rb Resolved
Comment thread Library/Homebrew/cmd/update-report.rb Resolved
Comment thread Library/Homebrew/cmd/update-report.rb Resolved
Comment thread Library/Homebrew/cmd/update-report.rb Resolved
HaraldNordgren and others added 5 commits November 1, 2026 16:51
- 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.
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@HaraldNordgren
HaraldNordgren force-pushed the update-notice-non-default-branch branch from 485e4ce to f3acb38 Compare November 1, 2026 15:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up Comments

Outside diff 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

Open the source location


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: 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.

Comment thread Library/Homebrew/cmd/update-report.rb Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1
Library/Homebrew/test/cmd/update-report_spec.rb: 1

147-168: Trivial · Maintainability & Code Quality · Quick win

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.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now thanks!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge November 1, 2026 16:37
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Nov 1, 2026
@HaraldNordgren

Copy link
Copy Markdown
Member Author

Looks good now thanks!

Thanks for the help here!

Merged via the queue into main with commit 41faef3 Nov 1, 2026
54 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the update-notice-non-default-branch branch November 1, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址