Tweak/fix Git remote configuration behaviour.

This commit is contained in:
Mike McQuaid 2019-12-30 10:38:47 +00:00
parent 674259d691
commit 355626ac51
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
8 changed files with 55 additions and 27 deletions

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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`.

View File

@ -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`.

View File

@ -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

View File

@ -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\.
.