Honor GIT env var
This commit is contained in:
parent
5e0cbdab9b
commit
b104623f43
@ -369,6 +369,15 @@ can take several different forms:
|
|||||||
|
|
||||||
## ENVIRONMENT
|
## ENVIRONMENT
|
||||||
|
|
||||||
|
* GIT:
|
||||||
|
When using Git, Homebrew will use `GIT` if set,
|
||||||
|
a Homebrew-built Git if installed, or the system-provided binary.
|
||||||
|
|
||||||
|
Set this to force Homebrew to use a particular git binary.
|
||||||
|
|
||||||
|
* EDITOR:
|
||||||
|
If set, and `HOMEBREW_EDITOR` is not, use `EDITOR` as the text editor.
|
||||||
|
|
||||||
* HOMEBREW\_BUILD\_FROM\_SOURCE:
|
* HOMEBREW\_BUILD\_FROM\_SOURCE:
|
||||||
If set, instructs Homebrew to compile from source even when a formula
|
If set, instructs Homebrew to compile from source even when a formula
|
||||||
provides a bottle.
|
provides a bottle.
|
||||||
|
|||||||
@ -315,6 +315,7 @@ end
|
|||||||
class GitDownloadStrategy < AbstractDownloadStrategy
|
class GitDownloadStrategy < AbstractDownloadStrategy
|
||||||
def initialize name, package
|
def initialize name, package
|
||||||
super
|
super
|
||||||
|
@@git ||= find_git
|
||||||
@unique_token="#{name}--git" unless name.to_s.empty? or name == '__UNKNOWN__'
|
@unique_token="#{name}--git" unless name.to_s.empty? or name == '__UNKNOWN__'
|
||||||
@clone=HOMEBREW_CACHE+@unique_token
|
@clone=HOMEBREW_CACHE+@unique_token
|
||||||
end
|
end
|
||||||
@ -339,7 +340,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
if @clone.exist?
|
if @clone.exist?
|
||||||
Dir.chdir(@clone) do
|
Dir.chdir(@clone) do
|
||||||
# Check for interupted clone from a previous install
|
# Check for interupted clone from a previous install
|
||||||
unless system 'git', 'status', '-s'
|
unless system @@git, 'status', '-s'
|
||||||
puts "Removing invalid .git repo from cache"
|
puts "Removing invalid .git repo from cache"
|
||||||
FileUtils.rm_rf @clone
|
FileUtils.rm_rf @clone
|
||||||
end
|
end
|
||||||
@ -348,7 +349,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
unless @clone.exist?
|
unless @clone.exist?
|
||||||
# Note: first-time checkouts are always done verbosely
|
# Note: first-time checkouts are always done verbosely
|
||||||
clone_args = %w[git clone]
|
clone_args = [@@git, 'clone']
|
||||||
clone_args << '--depth' << '1' if support_depth?
|
clone_args << '--depth' << '1' if support_depth?
|
||||||
|
|
||||||
case @spec
|
case @spec
|
||||||
@ -361,15 +362,15 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
else
|
else
|
||||||
puts "Updating #{@clone}"
|
puts "Updating #{@clone}"
|
||||||
Dir.chdir(@clone) do
|
Dir.chdir(@clone) do
|
||||||
safe_system 'git', 'config', 'remote.origin.url', @url
|
safe_system @@git, 'config', 'remote.origin.url', @url
|
||||||
|
|
||||||
safe_system 'git', 'config', 'remote.origin.fetch', case @spec
|
safe_system @@git, 'config', 'remote.origin.fetch', case @spec
|
||||||
when :branch then "+refs/heads/#{@ref}:refs/remotes/origin/#{@ref}"
|
when :branch then "+refs/heads/#{@ref}:refs/remotes/origin/#{@ref}"
|
||||||
when :tag then "+refs/tags/#{@ref}:refs/tags/#{@ref}"
|
when :tag then "+refs/tags/#{@ref}:refs/tags/#{@ref}"
|
||||||
else '+refs/heads/master:refs/remotes/origin/master'
|
else '+refs/heads/master:refs/remotes/origin/master'
|
||||||
end
|
end
|
||||||
|
|
||||||
git_args = %w[git fetch origin]
|
git_args = [@@git, 'fetch', 'origin']
|
||||||
quiet_safe_system(*git_args)
|
quiet_safe_system(*git_args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -382,27 +383,34 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
ohai "Checking out #{@spec} #{@ref}"
|
ohai "Checking out #{@spec} #{@ref}"
|
||||||
case @spec
|
case @spec
|
||||||
when :branch
|
when :branch
|
||||||
nostdout { quiet_safe_system 'git', 'checkout', "origin/#{@ref}", '--' }
|
nostdout { quiet_safe_system @@git, 'checkout', "origin/#{@ref}", '--' }
|
||||||
when :tag, :revision
|
when :tag, :revision
|
||||||
nostdout { quiet_safe_system 'git', 'checkout', @ref, '--' }
|
nostdout { quiet_safe_system @@git, 'checkout', @ref, '--' }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# otherwise the checkout-index won't checkout HEAD
|
# otherwise the checkout-index won't checkout HEAD
|
||||||
# https://github.com/mxcl/homebrew/issues/7124
|
# https://github.com/mxcl/homebrew/issues/7124
|
||||||
# must specify origin/HEAD, otherwise it resets to the current local HEAD
|
# must specify origin/HEAD, otherwise it resets to the current local HEAD
|
||||||
quiet_safe_system "git", "reset", "--hard", "origin/HEAD"
|
quiet_safe_system @@git, "reset", "--hard", "origin/HEAD"
|
||||||
end
|
end
|
||||||
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
|
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
|
||||||
safe_system 'git', 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
|
safe_system @@git, 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
|
||||||
# check for submodules
|
# check for submodules
|
||||||
if File.exist?('.gitmodules')
|
if File.exist?('.gitmodules')
|
||||||
safe_system 'git', 'submodule', 'init'
|
safe_system @@git, 'submodule', 'init'
|
||||||
safe_system 'git', 'submodule', 'update'
|
safe_system @@git, 'submodule', 'update'
|
||||||
sub_cmd = "git checkout-index -a -f \"--prefix=#{dst}/$path/\""
|
sub_cmd = "#{@@git} checkout-index -a -f \"--prefix=#{dst}/$path/\""
|
||||||
safe_system 'git', 'submodule', '--quiet', 'foreach', '--recursive', sub_cmd
|
safe_system @@git, 'submodule', '--quiet', 'foreach', '--recursive', sub_cmd
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Try GIT, a Homebrew-built Git, and finally the OS X system Git.
|
||||||
|
def find_git
|
||||||
|
return ENV['GIT'] if ENV['GIT']
|
||||||
|
return "#{HOMEBREW_PREFIX}/bin/git" if File.exist? "#{HOMEBREW_PREFIX}/bin/git"
|
||||||
|
return MacOS.locate 'git'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CVSDownloadStrategy < AbstractDownloadStrategy
|
class CVSDownloadStrategy < AbstractDownloadStrategy
|
||||||
|
|||||||
@ -409,6 +409,17 @@ Homebrew can install formulae via URL, e\.g\. \fBhttps://raw\.github\.com/mxcl/h
|
|||||||
.SH "ENVIRONMENT"
|
.SH "ENVIRONMENT"
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
GIT
|
||||||
|
When using Git, Homebrew will use \fBGIT\fR if set, a Homebrew\-built Git if installed, or the system\-provided binary\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
Set this to force Homebrew to use a particular git binary\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
EDITOR
|
||||||
|
If set, and \fBHOMEBREW_EDITOR\fR is not, use \fBEDITOR\fR as the text editor\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
HOMEBREW_BUILD_FROM_SOURCE
|
HOMEBREW_BUILD_FROM_SOURCE
|
||||||
If set, instructs Homebrew to compile from source even when a formula provides a bottle\.
|
If set, instructs Homebrew to compile from source even when a formula provides a bottle\.
|
||||||
.
|
.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user