Sha256: 5b4c30536adc2e3e397db2e0c77ae96d7338410a4a6fee40133ef7088e2ef8d6
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
class External include Sys::Client def self.externals_of(parent, prop = `svn propget svn:externals #{parent}`) exts = [] prop.split("\n").each do |prop_line| next if prop_line.strip.empty? exts << External.from_property_line(parent, prop_line) end exts end attr_reader :name, :path, :url, :revision def self.from_property_line(parent, property_line) match = /^(\S+)\s+(-r\s*\d*\s+)?(\S+)\s*$/.match(property_line) name = match[1] revision = match[2] ? match[2].gsub(/\D/,'').to_i : nil url = match[3] raise "no url found for '#{property_line}'" if url.nil? new(parent, name, url, revision) end def initialize(parent, name, url, revision = nil) @name = name @revision = revision @url = url @path = "#{parent}/#{@name}" end def ==(other) (path == other.path and url == other.url) end def to_s "#{name} " + (revision ? "-r #{revision} " : "") + url end def revision_actual info = `svn info #{@path}` info.grep(/^Revision:/).first.gsub(/Revision: /, '').to_i end def should_update? revision == nil || revision_actual != revision end #todo: test? (indirectly tested via root.rb) def update raise "path is nil" if path.nil? say "Updating external #{path}" run("svn cleanup #{path}") rev = revision.nil? ? '' : "-r#{revision}" svn("up #{rev} #{path}", true) end def checkout say "Checking out external #{path}" rev = revision.nil? ? '' : "-r#{revision}" svn("co #{rev} #{url} #{path}") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sub-0.4.0 | lib/sub/external.rb |
sub-0.4.2 | lib/sub/external.rb |
sub-0.4.1 | lib/sub/external.rb |