mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
GitDownloadStrategy: extract checkout from #stage
This commit is contained in:
parent
8b27989d11
commit
02ad6442e7
@ -321,6 +321,8 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
Dir.chdir(@clone) do
|
Dir.chdir(@clone) do
|
||||||
config_repo
|
config_repo
|
||||||
fetch_repo
|
fetch_repo
|
||||||
|
checkout
|
||||||
|
update_submodules if submodules?
|
||||||
end
|
end
|
||||||
elsif @clone.exist?
|
elsif @clone.exist?
|
||||||
puts "Removing invalid .git repo from cache"
|
puts "Removing invalid .git repo from cache"
|
||||||
@ -336,12 +338,6 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
Dir.chdir @clone do
|
Dir.chdir @clone do
|
||||||
if @spec and @ref
|
if @spec and @ref
|
||||||
ohai "Checking out #@spec #@ref"
|
ohai "Checking out #@spec #@ref"
|
||||||
case @spec
|
|
||||||
when :branch
|
|
||||||
nostdout { quiet_safe_system @@git, 'checkout', { :quiet_flag => '-q' }, "origin/#{@ref}", '--' }
|
|
||||||
when :tag, :revision
|
|
||||||
nostdout { quiet_safe_system @@git, 'checkout', { :quiet_flag => '-q' }, @ref, '--' }
|
|
||||||
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
|
||||||
@ -402,6 +398,21 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
def clone_repo
|
def clone_repo
|
||||||
safe_system @@git, *clone_args
|
safe_system @@git, *clone_args
|
||||||
|
@clone.cd do
|
||||||
|
checkout
|
||||||
|
update_submodules if submodules?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def checkout
|
||||||
|
ref = case @spec
|
||||||
|
when :branch then "origin/#@ref"
|
||||||
|
when :tag, :revision then @ref
|
||||||
|
end
|
||||||
|
|
||||||
|
nostdout do
|
||||||
|
quiet_safe_system @@git, 'checkout', { :quiet_flag => '-q' }, ref, '--'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_submodules
|
def update_submodules
|
||||||
|
Loading…
x
Reference in New Issue
Block a user