-
-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automatically repair tap with renamed main branch #19196
base: master
Are you sure you want to change the base?
Conversation
550786f
to
f304f80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far! Are there any performance implications for brew update
in the non-repair case? Can test this out with hyperfine
.
This should cost roughly 10ms per tap, because we're running The extra The use of this cache was removed in the first commit on this branch. I just removed the creation of this cache in my latest commit/push because it's an unused variable. If you're concerned about the time savings I could revert the last commit and use a temp file to track any renames; then we could invalidate the cache only when we need to. This would save some time, at the cost of complexity. Any thoughts? I'm happy to implement this either way, but I slightly prefer it in the current state I've committed: the cache I removed provided a tiny time savings and made code harder to read and debug. |
Feels like it might be nicer/safer to do this rename not in a subshell and set some marker file indicating that we don't need to check it again every Or is this the caching you're referring to above? In my mind (correct me if wrong!) the ideal flow would be something like:
Thoughts? Thanks for the PR! |
88629f9
to
e23db43
Compare
@MikeMcQuaid, that's an accurate summary of the workflow. That's what we were already doing before this PR, except we were printing an error annoucing that we discovered the rename rather than fixing it. Latest push is a refactor to:
To be clear, we're not running any extra code in the base case (when taps are reachable and not renamed). The rename check was always taken care of in error handling, and nothing in this PR changes that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rrotter! Just to set expectations: because this is update code and any breakage here potentially requires manual intervention for all Homebrew users: I'm going to be very conservative with review. Apologies for that.
As a homebrew user, I'd expect nothing less. Thank you for your forthrightness. (I'll follow up on the code comments later today or over the weekend) |
3a2b45d
to
747c078
Compare
Rewrote this based upon feedback. As is, this will handle renames of third party and non-core taps. This can handle renaming the brew repo and core repo as well, but we run into edge cases when I'd like to look at those edge cases a bit more before marking this as "Ready for review". There is probably another PR in order for fixing the handling of repo initialization wrt non-master branch names. |
When fetching git repos, automatically correct local branch name if we find the remote HEAD was renamed.
No longer needed, as cmd/update fixes renamed remotes instead.
6846822
to
04c054d
Compare
04c054d
to
3af62c9
Compare
Don't `git fetch` immediately upon setting custom git remote. Instead, fetch using the same code that fetches taps and default remotes. This code path already includes detection of mirror renames, so we don't need to implement this detection twice. This change should also make `brew update` slightly faster for users of brew mirrors.
3af62c9
to
5da05f0
Compare
- always default to master (apple git defaults to `main`) - rename if this turns out not to match the remote - set upstream tracking branch
Update 9aee398 to be agnostic to the name of main branch.
Use the detected upstream branch name when instructing user to `git reset --hard`.
ed3438a
to
bc6aadf
Compare
This now handles branch renames for all taps as well as brew itself, including the edge cases I mentioned in my last post. Additions are entirely agnostic as to what the upstream branch is called: renames to/from master/main/whatever are all handled the same way. I found several adjacent issues with how the update code handles branch names, and this PR snowballed to be a lot larger than expected. I can break off parts of this into separate PRs if you prefer. |
Yes please 🙇🏻. With PRs like this: as many small PRs as possible is ideal. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?When fetching git repos, automatically correct local branch name if we find the remote HEAD was renamed.
Completely reworked PR; to the point that my original comment doesn't make sense anymore. Original comment follows.
First step to fixing #17296.
We already have robust support for both detecting and fixing taps with renamed upstream HEAD. This puts those two together.
brew tap --repair foo/bar
update.sh
, runbrew tap --repair
on any taps where we detect renamed upstream HEADgit fetch
attempt, only if we detect renamebrew tap --repair
, retrygit fetch