download_strategy: rename @spec to @ref_type
This commit is contained in:
parent
88e5c4c333
commit
c790a4f45e
@ -10,7 +10,7 @@ class AbstractDownloadStrategy
|
|||||||
@resource = resource
|
@resource = resource
|
||||||
@url = resource.url
|
@url = resource.url
|
||||||
specs = resource.specs
|
specs = resource.specs
|
||||||
@spec, @ref = specs.dup.shift unless specs.empty?
|
@ref_type, @ref = specs.dup.shift unless specs.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def expand_safe_system_args args
|
def expand_safe_system_args args
|
||||||
@ -331,9 +331,9 @@ class SubversionDownloadStrategy < AbstractDownloadStrategy
|
|||||||
@co.rmtree
|
@co.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
if @spec == :revision
|
if @ref_type == :revision
|
||||||
fetch_repo @co, @url, @ref
|
fetch_repo @co, @url, @ref
|
||||||
elsif @spec == :revisions
|
elsif @ref_type == :revisions
|
||||||
# nil is OK for main_revision, as fetch_repo will then get latest
|
# nil is OK for main_revision, as fetch_repo will then get latest
|
||||||
main_revision = @ref.delete :trunk
|
main_revision = @ref.delete :trunk
|
||||||
fetch_repo @co, @url, main_revision, true
|
fetch_repo @co, @url, main_revision, true
|
||||||
@ -448,8 +448,8 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
def stage
|
def stage
|
||||||
dst = Dir.getwd
|
dst = Dir.getwd
|
||||||
Dir.chdir @clone do
|
Dir.chdir @clone do
|
||||||
if @spec and @ref
|
if @ref_type and @ref
|
||||||
ohai "Checking out #@spec #@ref"
|
ohai "Checking out #@ref_type #@ref"
|
||||||
else
|
else
|
||||||
reset
|
reset
|
||||||
end
|
end
|
||||||
@ -470,7 +470,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def support_depth?
|
def support_depth?
|
||||||
@spec != :revision and host_supports_depth?
|
@ref_type != :revision and host_supports_depth?
|
||||||
end
|
end
|
||||||
|
|
||||||
def host_supports_depth?
|
def host_supports_depth?
|
||||||
@ -489,7 +489,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
args = %w{clone}
|
args = %w{clone}
|
||||||
args << '--depth' << '1' if support_depth?
|
args << '--depth' << '1' if support_depth?
|
||||||
|
|
||||||
case @spec
|
case @ref_type
|
||||||
when :branch, :tag then args << '--branch' << @ref
|
when :branch, :tag then args << '--branch' << @ref
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def refspec
|
def refspec
|
||||||
case @spec
|
case @ref_type
|
||||||
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"
|
||||||
@ -510,7 +510,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_repo
|
def update_repo
|
||||||
unless @spec == :tag && has_ref?
|
unless @ref_type == :tag && has_ref?
|
||||||
quiet_safe_system @@git, 'fetch', 'origin'
|
quiet_safe_system @@git, 'fetch', 'origin'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -521,7 +521,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def checkout_args
|
def checkout_args
|
||||||
ref = case @spec
|
ref = case @ref_type
|
||||||
when :branch, :tag, :revision then @ref
|
when :branch, :tag, :revision then @ref
|
||||||
else `git symbolic-ref refs/remotes/origin/HEAD`.strip.split("/").last
|
else `git symbolic-ref refs/remotes/origin/HEAD`.strip.split("/").last
|
||||||
end
|
end
|
||||||
@ -536,7 +536,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reset_args
|
def reset_args
|
||||||
ref = case @spec
|
ref = case @ref_type
|
||||||
when :branch then "origin/#@ref"
|
when :branch then "origin/#@ref"
|
||||||
when :revision, :tag then @ref
|
when :revision, :tag then @ref
|
||||||
else "origin/HEAD"
|
else "origin/HEAD"
|
||||||
@ -656,8 +656,8 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy
|
|||||||
def stage
|
def stage
|
||||||
dst=Dir.getwd
|
dst=Dir.getwd
|
||||||
Dir.chdir @clone do
|
Dir.chdir @clone do
|
||||||
if @spec and @ref
|
if @ref_type and @ref
|
||||||
ohai "Checking out #{@spec} #{@ref}"
|
ohai "Checking out #{@ref_type} #{@ref}"
|
||||||
safe_system hgpath, 'archive', '--subrepos', '-y', '-r', @ref, '-t', 'files', dst
|
safe_system hgpath, 'archive', '--subrepos', '-y', '-r', @ref, '-t', 'files', dst
|
||||||
else
|
else
|
||||||
safe_system hgpath, 'archive', '--subrepos', '-y', '-t', 'files', dst
|
safe_system hgpath, 'archive', '--subrepos', '-y', '-t', 'files', dst
|
||||||
@ -743,8 +743,8 @@ class FossilDownloadStrategy < AbstractDownloadStrategy
|
|||||||
def stage
|
def stage
|
||||||
# TODO: The 'open' and 'checkout' commands are very noisy and have no '-q' option.
|
# TODO: The 'open' and 'checkout' commands are very noisy and have no '-q' option.
|
||||||
safe_system fossilpath, 'open', @clone
|
safe_system fossilpath, 'open', @clone
|
||||||
if @spec and @ref
|
if @ref_type and @ref
|
||||||
ohai "Checking out #{@spec} #{@ref}"
|
ohai "Checking out #{@ref_type} #{@ref}"
|
||||||
safe_system fossilpath, 'checkout', @ref
|
safe_system fossilpath, 'checkout', @ref
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user