class BetweenMeals::Repo::Svn
Public Instance Methods
Source
# File lib/between_meals/repo/svn.rb, line 58 def changes(start_ref, end_ref) valid_ref?(start_ref) valid_ref?(end_ref) if end_ref @logger.info("Diff between #{start_ref} and #{end_ref}") changes = @cmd.diff(start_ref, end_ref, @repo_path).stdout begin parse_status(changes).compact rescue StandardError => e @logger.error( 'Something went wrong. Please report this output.', ) @logger.error(e) stdout.lines.each do |line| @logger.error(line.strip) end exit(1) end end
Return files changed between two revisions
Source
# File lib/between_meals/repo/svn.rb, line 53 def checkout(url) @cmd.co(url, @repo_path) end
Source
# File lib/between_meals/repo/svn.rb, line 35 def exists? Dir.exist?(Pathname.new(@repo_path).join('.svn')) end
Source
# File lib/between_meals/repo/svn.rb, line 85 def files @cmd.ls.stdout.split("\n").map do |x| { :path => x, :status => :created } end end
Source
# File lib/between_meals/repo/svn.rb, line 39 def head_rev @cmd.info(@repo_path).stdout.each_line do |line| m = line.match(/Last Changed Rev: (\d+)$/) return m[1] if m end end
Source
# File lib/between_meals/repo/svn.rb, line 46 def latest_revision @cmd.info(@repo_path).stdout.each_line do |line| m = line.match(/Revision: (\d+)$/) return m[1] if m end end
Source
# File lib/between_meals/repo/svn.rb, line 26 def setup @bin = 'svn' @cmd = BetweenMeals::Repo::Svn::Cmd.new( :bin => @bin, :cwd => '/tmp', :logger => @logger, ) end
Source
# File lib/between_meals/repo/svn.rb, line 79 def update @cmd.cleanup(@repo_path) @cmd.revert(@repo_path) @cmd.update(@repo_path) end
Source
# File lib/between_meals/repo/svn.rb, line 93 def valid_ref?(ref) @cmd.info_r(ref, @repo_path) rescue StandardError raise Changeset::ReferenceError end
Private Instance Methods
Source
# File lib/between_meals/repo/svn.rb, line 101 def parse_status(changes) # http://svnbook.red-bean.com/en/1.0/re26.html changes.lines.map do |line| case line when /^([\w ])\w?\s+(.+)$/ { :status => Regexp.last_match(1) == 'D' ? :deleted : :modified, :path => Regexp.last_match(2).sub("#{@repo_path}/", ''), } else fail 'Failed to parse repo diff line.' end end end