Merge pull request #6667 from hyuraku/add_change_origin_command
add new command to set url to remote origin
This commit is contained in:
commit
abfb5b1c84
@ -374,6 +374,26 @@ then
|
||||
export HOMEBREW_BOTTLE_DOMAIN="$HOMEBREW_BOTTLE_DEFAULT_DOMAIN"
|
||||
fi
|
||||
|
||||
HOMEBREW_DEFAULT_BREW_GIT_REMOTE="https://github.com/Homebrew/brew"
|
||||
if [[ -z "$HOMEBREW_BREW_GIT_REMOTE" ]]
|
||||
then
|
||||
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_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
|
||||
else
|
||||
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"
|
||||
|
||||
@ -23,14 +23,6 @@ git() {
|
||||
}
|
||||
|
||||
git_init_if_necessary() {
|
||||
BREW_OFFICIAL_REMOTE="https://github.com/Homebrew/brew"
|
||||
if [[ -n "$HOMEBREW_MACOS" ]] || [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]]
|
||||
then
|
||||
CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/homebrew-core"
|
||||
else
|
||||
CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/linuxbrew-core"
|
||||
fi
|
||||
|
||||
safe_cd "$HOMEBREW_REPOSITORY"
|
||||
if [[ ! -d ".git" ]]
|
||||
then
|
||||
@ -38,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 "$BREW_OFFICIAL_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"
|
||||
@ -56,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 "$CORE_OFFICIAL_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
|
||||
@ -402,6 +394,24 @@ EOS
|
||||
|
||||
git_init_if_necessary
|
||||
|
||||
if [[ "$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
|
||||
then
|
||||
safe_cd "$HOMEBREW_REPOSITORY"
|
||||
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_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_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
|
||||
|
||||
safe_cd "$HOMEBREW_REPOSITORY"
|
||||
|
||||
# if an older system had a newer curl installed, change each repo's remote URL from GIT to HTTPS
|
||||
@ -409,8 +419,8 @@ EOS
|
||||
-x "$HOMEBREW_PREFIX/opt/curl/bin/curl" &&
|
||||
"$(git config remote.origin.url)" =~ ^git:// ]]
|
||||
then
|
||||
git config remote.origin.url "$BREW_OFFICIAL_REMOTE"
|
||||
git config -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "$CORE_OFFICIAL_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
|
||||
|
||||
@ -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,11 +560,11 @@ module Homebrew
|
||||
end
|
||||
|
||||
def check_brew_git_origin
|
||||
examine_git_origin(HOMEBREW_REPOSITORY, "Homebrew/brew")
|
||||
examine_git_origin(HOMEBREW_REPOSITORY, HOMEBREW_BREW_GIT_REMOTE)
|
||||
end
|
||||
|
||||
def check_coretap_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
|
||||
|
||||
@ -98,7 +98,7 @@ module HomebrewArgvExtension
|
||||
end
|
||||
|
||||
def build_bottle?
|
||||
include?("--build-bottle") || !ENV["HOMEBREW_BUILD_BOTTLE"].nil?
|
||||
include?("--build-bottle")
|
||||
end
|
||||
|
||||
def bottle_arch
|
||||
|
||||
@ -53,6 +53,9 @@ HOMEBREW_USER_AGENT_FAKE_SAFARI =
|
||||
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"]
|
||||
HOMEBREW_BOTTLE_DOMAIN = ENV["HOMEBREW_BOTTLE_DOMAIN"]
|
||||
|
||||
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"
|
||||
|
||||
|
||||
@ -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`.
|
||||
|
||||
@ -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`.
|
||||
|
||||
@ -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\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user