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
tap: allow to change tap remote with brew tap --custom-remote
#12221
Conversation
brew tap --force
brew tap --force
@XuehaiPan I like the idea of the functionality but I'm not sure about:
|
The git -C "$(brew --repo homebrew/repo)" remote set-url origin <REMOTE-URL>
In the docs for Homebrew Git Mirroring at TUNA: # Set manually
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
git -C "$(brew --repo homebrew/cask-versions)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-versions.git
git -C "$(brew --repo homebrew/command-not-found)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-command-not-found.git
# Or use the following scripts
BREW_TAPS="$(BREW_TAPS="$(brew tap 2>/dev/null)"; echo -n "${BREW_TAPS//$'\n'/:}")"
for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do
if [[ ":${BREW_TAPS}:" == *":homebrew/${tap}:"* ]]; then # if installed
# Set the remote of tap to TUNA and mark as auto update
git -C "$(brew --repo homebrew/${tap})" remote set-url origin "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
git -C "$(brew --repo homebrew/${tap})" config homebrew.forceautoupdate true
else # install when not installed
brew tap --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
fi
done With the for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do
brew tap --force --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
done No error will raise with |
Not sure I agree, it could just error out.
This doesn't make sense to me, sounds like it should always e.g. retap even if already tapped.
I think we should consider adding this variable 👍🏻 Not sure about other taps because they aren't as slow.
I see. I think it's probably worth using a different name or adding more variables for these taps (or a generic way that doesn't require a separate variable for each tap). |
I mean
There are many official taps in Homebrew (cask, cask-fonts, command-not-found, bundle, etc.). If we add a variable for each tap repo, maybe it will make |
Yes, it sounds like it should change the remote when already installed. Maybe something like
Only homebrew-core and homebrew-cask are really slow from China though, right? I don't think they all need mirrored. It won't make
I think keeping it on |
I'm fine with the name. I can change the name of the new option in this PR if requested. I choose |
Yeh, a new name would be good. |
ec69bab
to
b25d846
Compare
brew tap --force
brew tap --custom-remote
I changed the name to |
266e1e2
to
7982686
Compare
This comment has been minimized.
This comment has been minimized.
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.
Looking good! A few more tweaks.
Thanks again @XuehaiPan! |
Head branch was pushed to by a user without write access
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Add option
--force
tobrew tap
for reset the tap remote.New tests have not been added yet, since we do not test
fix_remote_configuration
.