diff options
| author | Jack Nagel | 2014-12-03 17:25:51 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-12-03 17:25:51 -0500 | 
| commit | cfd99d3bebaf2de53ba3d50c46a69fc616c5e19c (patch) | |
| tree | e26848aa3b5f7db7e2f2fd33fc5398f8747a3fdd | |
| parent | 2dd7a8e801afc8ab14451af7c01cfad305ddd83d (diff) | |
| download | homebrew-cfd99d3bebaf2de53ba3d50c46a69fc616c5e19c.tar.bz2 | |
Make the git download strategy default to :branch => "master"
Fixes #33437.
| -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}} | 
