diff options
Diffstat (limited to 'Library/Homebrew/download_strategy.rb')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 24 | 
1 files changed, 5 insertions, 19 deletions
| diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index d915ff582..0d863ea4f 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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}} | 
