Make the git download strategy default to :branch => "master"

Fixes Homebrew/homebrew#33437.
This commit is contained in:
Jack Nagel 2014-12-03 17:25:51 -05:00
parent 0a8b0d4a5c
commit ed842246f7

View File

@ -444,6 +444,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
def initialize name, resource
super
@ref_type ||= :branch
@ref ||= "master"
@shallow = resource.specs.fetch(:shallow) { true }
end
@ -473,11 +475,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
def stage
dst = Dir.getwd
@clone.cd do
if @ref_type and @ref
ohai "Checking out #@ref_type #@ref"
else
reset
end
ohai "Checking out #{@ref_type} #{@ref}"
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
safe_system 'git', 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
checkout_submodules(dst) if submodules?
@ -535,9 +533,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
end
def update_repo
# Branches always need updated. The has_ref? check will only work if a ref
# has been specified; if there isn't one we always want an update.
if @ref_type == :branch || !@ref || !has_ref?
if @ref_type == :branch || !has_ref?
quiet_safe_system 'git', 'fetch', 'origin'
end
end
@ -547,24 +543,14 @@ class GitDownloadStrategy < VCSDownloadStrategy
@clone.cd { update_submodules } if submodules?
end
def checkout_args
ref = case @ref_type
when :branch, :tag, :revision then @ref
else `git symbolic-ref refs/remotes/origin/HEAD`.strip.split("/").last
end
%W{checkout -f #{ref}}
end
def checkout
quiet_safe_system 'git', *checkout_args
quiet_safe_system "git", "checkout", "-f", @ref, "--"
end
def reset_args
ref = case @ref_type
when :branch then "origin/#@ref"
when :revision, :tag then @ref
else "origin/HEAD"
end
%W{reset --hard #{ref}}