Class: SubversionDownloadStrategy

Inherits:
VCSDownloadStrategy show all
Defined in:
Library/Homebrew/download_strategy.rb

Overview

Strategy for downloading a Subversion repository.

Constant Summary

Constants inherited from VCSDownloadStrategy

VCSDownloadStrategy::REF_TYPES

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cache, #cached_location, #url

Instance Method Summary collapse

Methods inherited from VCSDownloadStrategy

#commit_outdated?, #fetch_last_commit, #head?

Methods inherited from AbstractDownloadStrategy

#basename, #clear_cache, #shutup!, #stage

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

#initialize(url, name, version, **meta) ⇒ SubversionDownloadStrategy

Returns a new instance of SubversionDownloadStrategy.


569
570
571
572
# File 'Library/Homebrew/download_strategy.rb', line 569

def initialize(url, name, version, **meta)
  super
  @url = @url.sub("svn+http://", "")
end

Instance Method Details

#fetchObject

Download and cache the repository at AbstractDownloadStrategy#cached_location.


577
578
579
580
581
582
# File 'Library/Homebrew/download_strategy.rb', line 577

def fetch
  if @url.chomp("/") != repo_url || !system_command("svn", args: ["switch", @url, cached_location]).success?
    clear_cache
  end
  super
end

#last_commitObject


597
598
599
600
# File 'Library/Homebrew/download_strategy.rb', line 597

def last_commit
  out, = system_command("svn", args: ["info", "--show-item", "revision"], chdir: cached_location)
  out.strip
end

#source_modified_timeObject

Returns the most recent modified time for all files in the current working directory after stage.


585
586
587
588
589
590
591
592
593
594
# File 'Library/Homebrew/download_strategy.rb', line 585

def source_modified_time
  time = if Version.create(Utils::Svn.version) >= Version.create("1.9")
    out, = system_command("svn", args: ["info", "--show-item", "last-changed-date"], chdir: cached_location)
    out
  else
    out, = system_command("svn", args: ["info"], chdir: cached_location)
    out[/^Last Changed Date: (.+)$/, 1]
  end
  Time.parse time
end