From 355626ac516c660e402c0187796dd020608519de Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 30 Dec 2019 10:38:47 +0000 Subject: [PATCH] Tweak/fix Git remote configuration behaviour. --- Library/Homebrew/brew.sh | 20 ++++++++++++-------- Library/Homebrew/cmd/update.sh | 16 ++++++++-------- Library/Homebrew/diagnostic.rb | 10 +++------- Library/Homebrew/global.rb | 4 ++-- Library/Homebrew/manpages/brew.1.md.erb | 10 ++++++++++ docs/Manpage.md | 10 ++++++++++ manpages/brew-cask.1 | 2 +- manpages/brew.1 | 10 +++++++++- 8 files changed, 55 insertions(+), 27 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 0974a6e2e3..baae79b50b 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -374,22 +374,26 @@ then export HOMEBREW_BOTTLE_DOMAIN="$HOMEBREW_BOTTLE_DEFAULT_DOMAIN" fi -export HOMEBREW_BREW_REMOTE -export HOMEBREW_DEFAULT_CORE_REMOTE - -HOMEBREW_DEFAULT_BREW_REMOTE="https://github.com/Homebrew/brew.git" -if [[ -z "$HOMEBREW_BREW_REMOTE" ]] +HOMEBREW_DEFAULT_BREW_GIT_REMOTE="https://github.com/Homebrew/brew" +if [[ -z "$HOMEBREW_BREW_GIT_REMOTE" ]] then - HOMEBREW_BREW_REMOTE="$HOMEBREW_DEFAULT_BREW_REMOTE" + HOMEBREW_BREW_GIT_REMOTE="$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" fi +export HOMEBREW_BREW_GIT_REMOTE if [[ -n "$HOMEBREW_MACOS" ]] || [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]] then - HOMEBREW_DEFAULT_CORE_REMOTE="https://github.com/Homebrew/homebrew-core" + HOMEBREW_DEFAULT_CORE_GIT_REMOTE="https://github.com/Homebrew/homebrew-core" else - HOMEBREW_DEFAULT_CORE_REMOTE="https://github.com/Homebrew/linuxbrew-core" + HOMEBREW_DEFAULT_CORE_GIT_REMOTE="https://github.com/Homebrew/linuxbrew-core" fi +if [[ -z "$HOMEBREW_CORE_GIT_REMOTE" ]] +then + HOMEBREW_CORE_GIT_REMOTE="$HOMEBREW_DEFAULT_CORE_GIT_REMOTE" +fi +export HOMEBREW_CORE_GIT_REMOTE + if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] then HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 4d50c0300c..2cbab43ca0 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -30,7 +30,7 @@ git_init_if_necessary() { trap '{ rm -rf .git; exit 1; }' EXIT git init git config --bool core.autocrlf false - git config remote.origin.url "$HOMEBREW_BREW_REMOTE" + git config remote.origin.url "$HOMEBREW_BREW_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" git fetch --force origin --shallow-since="$latest_tag" @@ -48,7 +48,7 @@ git_init_if_necessary() { trap '{ rm -rf .git; exit 1; }' EXIT git init git config --bool core.autocrlf false - git config remote.origin.url "$HOMEBREW_CORE_REMOTE" + git config remote.origin.url "$HOMEBREW_CORE_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master git reset --hard origin/master @@ -394,20 +394,20 @@ EOS git_init_if_necessary - if [[ "$HOMEBREW_DEFAULT_BREW_REMOTE" != "$HOMEBREW_BREW_REMOTE" ]] + if [[ "$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]] then safe_cd "$HOMEBREW_REPOSITORY" - git remote set-url origin "$HOMEBREW_BREW_REMOTE" + git remote set-url origin "$HOMEBREW_BREW_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" git fetch --force origin --shallow-since="$latest_tag" fi - if [[ "$HOMEBREW_DEFAULT_CORE_REMOTE" != "$HOMEBREW_CORE_REMOTE" ]] && + if [[ "$HOMEBREW_DEFAULT_CORE_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] && [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] then safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" - git remote set-url origin "$HOMEBREW_CORE_REMOTE" + git remote set-url origin "$HOMEBREW_CORE_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master fi @@ -419,8 +419,8 @@ EOS -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" && "$(git config remote.origin.url)" =~ ^git:// ]] then - git config remote.origin.url "$HOMEBREW_BREW_REMOTE" - git config -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "$HOMEBREW_CORE_REMOTE" + git config remote.origin.url "$HOMEBREW_BREW_GIT_REMOTE" + git config -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "$HOMEBREW_CORE_GIT_REMOTE" fi # kill all of subprocess on interrupt diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index c038311219..27b4922dca 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -130,7 +130,7 @@ module Homebrew With a non-standard origin, Homebrew won't update properly. You can solve this by setting the origin remote: - git -C "#{repository_path}" remote set-url origin #{Formatter.url("https://github.com/#{desired_origin}.git")} + git -C "#{repository_path}" remote set-url origin #{Formatter.url("https://github.com/#{desired_origin}")} EOS end end @@ -560,15 +560,11 @@ module Homebrew end def check_brew_git_origin - return if HOMEBREW_BREW_REMOTE == HOMEBREW_REPOSITORY.git_origin - - examine_git_origin(HOMEBREW_REPOSITORY, "Homebrew/brew") + examine_git_origin(HOMEBREW_REPOSITORY, HOMEBREW_BREW_GIT_REMOTE) end def check_coretap_git_origin - return if HOMEBREW_BREW_REMOTE == CoreTap.instance.path.git_origin - - examine_git_origin(CoreTap.instance.path, CoreTap.instance.full_name) + examine_git_origin(CoreTap.instance.path, HOMEBREW_CORE_GIT_REMOTE) end def check_casktap_git_origin diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index c016193b09..8f0aa52a2b 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -53,8 +53,8 @@ HOMEBREW_USER_AGENT_FAKE_SAFARI = HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"] HOMEBREW_BOTTLE_DOMAIN = ENV["HOMEBREW_BOTTLE_DOMAIN"] -HOMEBREW_BREW_REMOTE = ENV["HOMEBREW_BREW_REMOTE"] -HOMEBREW_CORE_REMOTE = ENV["HOMEBREW_CORE_REMOTE"] +HOMEBREW_BREW_GIT_REMOTE = ENV["HOMEBREW_BREW_GIT_REMOTE"] +HOMEBREW_CORE_GIT_REMOTE = ENV["HOMEBREW_CORE_GIT_REMOTE"] HOMEBREW_DEFAULT_PREFIX = "/usr/local" LINUXBREW_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew" diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 2cdd3f9130..b9d9bc0f8d 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -152,6 +152,11 @@ Note that environment variables must have a value set to be detected. For exampl URL. For example, `HOMEBREW_BOTTLE_DOMAIN=http://localhost:8080` will cause all bottles to download from the prefix `http://localhost:8080/`. + * `HOMEBREW_BREW_GIT_REMOTE`: + By default, Homebrew uses `https://github.com/Homebrew/brew` as its + Homebrew/brew `git`(1) remote. If set, instructs Homebrew to instead use + the specified URL. + * `HOMEBREW_BROWSER`: If set, Homebrew uses this setting as the browser when opening project homepages, instead of the OS default browser. @@ -161,6 +166,11 @@ Note that environment variables must have a value set to be detected. For exampl *Default:* `~/Library/Caches/Homebrew`. + * `HOMEBREW_CORE_GIT_REMOTE`: + By default, Homebrew uses `https://github.com/Homebrew/homebrew-core` (or + `https://github.com/Homebrew/linuxbrew-core`) as its Homebrew/homebrew-core + `git`(1) remote. If set, instructs Homebrew to instead use the specified URL. + * `HOMEBREW_CURLRC`: If set, Homebrew will not pass `-q` when invoking `curl`(1), which disables the use of `curlrc`. diff --git a/docs/Manpage.md b/docs/Manpage.md index f8ce7fd0c6..116363540f 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1090,6 +1090,11 @@ Note that environment variables must have a value set to be detected. For exampl URL. For example, `HOMEBREW_BOTTLE_DOMAIN=http://localhost:8080` will cause all bottles to download from the prefix `http://localhost:8080/`. + * `HOMEBREW_BREW_GIT_REMOTE`: + By default, Homebrew uses `https://github.com/Homebrew/brew` as its + Homebrew/brew `git`(1) remote. If set, instructs Homebrew to instead use + the specified URL. + * `HOMEBREW_BROWSER`: If set, Homebrew uses this setting as the browser when opening project homepages, instead of the OS default browser. @@ -1099,6 +1104,11 @@ Note that environment variables must have a value set to be detected. For exampl *Default:* `~/Library/Caches/Homebrew`. + * `HOMEBREW_CORE_GIT_REMOTE`: + By default, Homebrew uses `https://github.com/Homebrew/homebrew-core` (or + `https://github.com/Homebrew/linuxbrew-core`) as its Homebrew/homebrew-core + `git`(1) remote. If set, instructs Homebrew to instead use the specified URL. + * `HOMEBREW_CURLRC`: If set, Homebrew will not pass `-q` when invoking `curl`(1), which disables the use of `curlrc`. diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1 index 4abd0bad83..eb0c37fa05 100644 --- a/manpages/brew-cask.1 +++ b/manpages/brew-cask.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW\-CASK" "1" "November 2019" "Homebrew" "brew-cask" +.TH "BREW\-CASK" "1" "December 2019" "Homebrew" "brew-cask" . .SH "NAME" \fBbrew\-cask\fR \- a friendly binary installer for macOS diff --git a/manpages/brew.1 b/manpages/brew.1 index 9b7d29e5b4..0fa0825cac 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "November 2019" "Homebrew" "brew" +.TH "BREW" "1" "December 2019" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for macOS @@ -1347,6 +1347,10 @@ If set, Homebrew will use \fBbat\fR for the \fBbrew cat\fR command\. By default, Homebrew uses \fBhttps://homebrew\.bintray\.com/\fR as its download mirror for bottles\. If set, instructs Homebrew to instead use the specified URL\. For example, \fBHOMEBREW_BOTTLE_DOMAIN=http://localhost:8080\fR will cause all bottles to download from the prefix \fBhttp://localhost:8080/\fR\. . .TP +\fBHOMEBREW_BREW_GIT_REMOTE\fR +By default, Homebrew uses \fBhttps://github\.com/Homebrew/brew\fR as its Homebrew/brew \fBgit\fR(1) remote\. If set, instructs Homebrew to instead use the specified URL\. +. +.TP \fBHOMEBREW_BROWSER\fR If set, Homebrew uses this setting as the browser when opening project homepages, instead of the OS default browser\. . @@ -1358,6 +1362,10 @@ If set, instructs Homebrew to use the specified directory as the download cache\ \fIDefault:\fR \fB~/Library/Caches/Homebrew\fR\. . .TP +\fBHOMEBREW_CORE_GIT_REMOTE\fR +By default, Homebrew uses \fBhttps://github\.com/Homebrew/homebrew\-core\fR (or \fBhttps://github\.com/Homebrew/linuxbrew\-core\fR) as its Homebrew/homebrew\-core \fBgit\fR(1) remote\. If set, instructs Homebrew to instead use the specified URL\. +. +.TP \fBHOMEBREW_CURLRC\fR If set, Homebrew will not pass \fB\-q\fR when invoking \fBcurl\fR(1), which disables the use of \fBcurlrc\fR\. .