diff options
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 25 | 
1 files changed, 19 insertions, 6 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 4cc59daa6..417aee51a 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -695,18 +695,31 @@ class BazaarDownloadStrategy < AbstractDownloadStrategy        ].find { |p| File.executable? p }    end +  def repo_valid? +    @clone.join(".bzr").directory? +  end +    def fetch      ohai "Cloning #{@url}" -    unless @clone.exist? -      url=@url.sub(%r[^bzr://], '') -      # 'lightweight' means history-less -      safe_system bzrpath, 'checkout', '--lightweight', url, @clone -    else + +    if @clone.exist? && repo_valid?        puts "Updating #{@clone}" -      Dir.chdir(@clone) { safe_system bzrpath, 'update' } +      @clone.cd { safe_system bzrpath, 'update' } +    elsif @clone.exist? +      puts "Removing invalid bzr repo from cache" +      @clone.rmtree +      clone_repo +    else +      clone_repo      end    end +  def clone_repo +    url = @url.sub(%r[^bzr://], '') +    # 'lightweight' means history-less +    safe_system bzrpath, 'checkout', '--lightweight', url, @clone +  end +    def stage      # FIXME: The export command doesn't work on checkouts      # See https://bugs.launchpad.net/bzr/+bug/897511  | 
