Pull Request Overview
- Opened on October 19, 2026
- Status Merged
- Commit count 2 with first commit October 19, 2026
Total Delta
Open Days
Test Delta
How long has this pull request spent in each phase of its lifecycle?
| Fraction of total time | Business days | Phase |
|---|---|---|
|
|
0.0 days | Authoring 0 commits before pull request opened for review |
|
|
0.0 days | Awaiting first review |
|
|
0.3 days | Revising work with 2 commits in response to 4 reviews that left 15 comments |
| Set up deploy tracking to begin tracking full PR start-to-deploy times | ||
Total time for pull request
0.3 business days
from first commit authored to merge
Deploy tracking has not been set up
Warn when the upstream remote isn't `origin`
Homebrew assumes origin is Homebrew/brew: brew update fetches from it, and the --changed options (and so brew lgtm) compare against the merge-base with origin/HEAD. gh repo fork sets things up the other way round, with the fork as origin and Homebrew/brew as upstream, both with --clone and when run inside an existing clone. If the fork's default branch is behind, brew lgtm then checks every file changed upstream since then, without saying why.
This makes brew doctor and brew lgtm detect that layout, where origin isn't the expected repository but another remote is, and suggest renaming the remotes:
Warning: The current git origin is:
[email protected]:HaraldNordgren/brew.git
but the `upstream` remote is:
[email protected]:Homebrew/brew.git
With a non-standard origin, Homebrew won't update properly
and `--changed` options compare against the wrong branch.
You can solve this by renaming the remotes:
git -C "/path/to/brew" remote rename origin fork
git -C "/path/to/brew" remote rename upstream origin
brew lgtm shows it before running any checks, for the brew repository or an official tap. brew doctor already flagged a non-standard origin, but it suggested git remote set-url origin https://github.com/Homebrew/brew, which would replace the fork's URL, and it also reported SSH origins like [email protected]:Homebrew/brew.git as non-standard. Both are fixed here.
This replaces the earlier version of this PR, which made --changed look for the Homebrew/brew remote by URL.
How I got here
brew lgtm had been failing for me while installing formulae, before it got to any checks. My checkout had the layout gh repo fork creates: origin was my fork, whose origin/HEAD pointed at a master from August, about 1,450 commits behind, and upstream was Homebrew/brew. So --changed saw about 1,700 changed files, 54 of them shell or workflow files. brew style then needed shfmt, and because mine was outdated, ./bin/brew tried to build go from source on my macOS 12 machine and failed.
Once I realised why, I renamed my remotes so that origin is Homebrew/brew:
$ git remote -v
HaraldNordgren [email protected]:HaraldNordgren/brew.git (fetch)
HaraldNordgren [email protected]:HaraldNordgren/brew.git (push)
origin [email protected]:Homebrew/brew.git (fetch)
origin [email protected]:Homebrew/brew.git (push)
After that, brew lgtm ran cleanly without installing anything. With this change, brew lgtm would have told me what to rename straight away.
Steps to reproduce
- In a clone of
Homebrew/brew, rungh repo fork --remote(or usegh repo fork Homebrew/brew --clone), with a fork whose default branch is behindHomebrew/brew. -
git switch -c some-change upstream/mainand change one Ruby file, e.g.Library/Homebrew/utils/git.rb. -
./bin/brew lgtmchecks every file changed upstream since the fork's default branch, and./bin/brew doctorsuggestsgit remote set-url origin https://github.com/Homebrew/brew, which would replace the fork's URL.
Changes
-
brew doctor: whenoriginisn't the expected repository but another remote is, suggest renaming the remotes rather thangit remote set-url. Accept GitHub SSH URLs fororigin. -
brew lgtm: show the same warning for the brew repository or an official tap before running any checks. - Add specs for both.
- [x] Have you followed our Contributing guidelines?
- [x] Have you checked for other open Pull Requests for the same change?
- [x] Have you explained what your changes do? Performance claims (e.g. "this is faster") must include
brew benchmarkresults. - [x] Have you explained why you'd like these changes included, not just what they do?
- [x] For bug fixes, have you given step-by-step
brewcommands to reproduce the bug? - [x] Have you written new tests (excluding integration tests)? Here's an example.
- [x] Have you successfully run
brew lgtm(style, typechecking and tests) locally?
- [x] 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) helped trace why brew lgtm was installing formulae and write the change and specs. The new specs fail without the change and pass with it, and brew lgtm passes locally.
Summary by CodeRabbit
-
Bug Fixes-
brew lgtmnow checks Git origins for repositories outside taps and for core and official taps, warning when an origin does not match the expected repository. - Recognised equivalent GitHub SSH and HTTPS URLs are accepted as matching origins.
- If another fetch remote matches the expected repository, the diagnostic identifies the remote and suggests making it
origin; otherwise, it retains the existing guidance for correcting the origin URL.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
-
Comments Threads Pending Resolution
> [!CAUTION]
> Some comments are outside the diff and canβt be posted inline due to GitHub limitations.
>
> **β οΈ Outside diff range comments (1)**
>
>
> π‘ Minor Β· Use a collision-free temporary remote when swapping remote names. Β· diagnostic.rb:214-234
>
> `Library/Homebrew/diagnostic.rb:214-234`
> **π― Functional Correctness** | **π‘ Minor** | **β‘ Quick win**
>
> **Use a collision-free temporary remote when swapping remote names.**
>
> When both `origin` and the matching `fork` remote exist, both remediation commands fail because each destination name is already occupied. The matching remote does not become `origin`.
>
>
> Suggested fix
>
> ```diff
> elsif desired_remote
> + remote_names = remotes.map { |line| line.split.first }.compact.uniq
> + temporary_remote = "homebrew-temp"
> + suffix = 0
> + while remote_names.include?(temporary_remote)
> + suffix += 1
> + temporary_remote = "homebrew-temp-#{suffix}"
> + end
> +
> Finding.new(
> @@
> - git -C "#{repository_path}" remote rename origin fork
> - git -C "#{repository_path}" remote rename #{desired_remote} origin
> + git -C "#{repository_path}" remote rename #{desired_remote} #{temporary_remote}
> + git -C "#{repository_path}" remote rename origin #{desired_remote}
> + git -C "#{repository_path}" remote rename #{temporary_remote} origin
> @@
> - "git -C \"#{repository_path}\" remote rename origin fork",
> - "git -C \"#{repository_path}\" remote rename #{desired_remote} origin",
> + "git -C \"#{repository_path}\" remote rename #{desired_remote} #{temporary_remote}",
> + "git -C \"#{repository_path}\" remote rename origin #{desired_remote}",
> + "git -C \"#{repository_path}\" remote rename #{temporary_remote} origin",
> ```
>
>
>
>
>
>
---
βΉοΈ Review info
βοΈ Run configuration
- **Configuration used**: Organization UI
- **Review profile**: CHILL
- **Plan**: Advanced
- **Run ID**: `51bb17f4-7c5f-4dd2-906f-2608f9680b7c`
π₯ Commits
Reviewing files that changed from the base of the PR and between a7cb8c7ef0be876e91a60a6b3cc306568f6e62a2 and e0ce0f378e0db2e94253b11c776ec48da9db9f4d.
π Files selected for processing: 4
* `Library/Homebrew/dev-cmd/lgtm.rb`
* `Library/Homebrew/diagnostic.rb`
* `Library/Homebrew/test/dev-cmd/lgtm_spec.rb`
* `Library/Homebrew/test/diagnostic_checks_spec.rb`
π§ Files skipped from review as they are similar to previous changes: 4
* Library/Homebrew/dev-cmd/lgtm.rb
* Library/Homebrew/test/diagnostic_checks_spec.rb
* Library/Homebrew/test/dev-cmd/lgtm_spec.rb
* Library/Homebrew/diagnostic.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.
**Actionable comments posted: 3**
---
βΉοΈ Review info
βοΈ Run configuration
- **Configuration used**: Organization UI
- **Review profile**: CHILL
- **Plan**: Advanced
- **Run ID**: `211fee93-08da-429b-a57f-a6dae71d040a`
π₯ Commits
Reviewing files that changed from the base of the PR and between 41f40decfa0789cff312806606757300bb8bd1c3 and a7cb8c7ef0be876e91a60a6b3cc306568f6e62a2.
π Files selected for processing: 4
* `Library/Homebrew/dev-cmd/lgtm.rb`
* `Library/Homebrew/diagnostic.rb`
* `Library/Homebrew/test/dev-cmd/lgtm_spec.rb`
* `Library/Homebrew/test/diagnostic_checks_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.
This seems potentially a bit error-prone than the existing status quo. This assumption is baked all over the place in the app. I'd suggest just using `origin` for Homebrew/brew instead?
Resolved Comment Threads
No resolved comments have been left on this PR.
Thanks!