class RakeCommit::Svn

Public Class Methods

new(prompt_exclusions = [], precommit = nil) click to toggle source
# File lib/rake_commit/svn.rb, line 6
def initialize(prompt_exclusions = [], precommit = nil)
  @prompt_exclusions = prompt_exclusions
  @precommit = precommit
end

Public Instance Methods

add() click to toggle source
# File lib/rake_commit/svn.rb, line 47
def add
  RakeCommit::Shell.backtick("svn st").split("\n").each do |line|
    if new_file?(line) && !svn_conflict_file?(line)
      file = line[7..-1].strip
      RakeCommit::Shell.system "svn add #{file.inspect}"
    end
  end
end
commit() click to toggle source
# File lib/rake_commit/svn.rb, line 11
def commit
  if files_to_check_in?
    message = RakeCommit::CommitMessage.new(@prompt_exclusions).joined_message_with_author
    RakeCommit::Shell.system(@precommit) unless @precommit.nil?
    add
    delete
    up
    RakeCommit::Shell.system "rake"
    output = RakeCommit::Shell.backtick "#{commit_command(message)}"
    puts output
    revision = output.match(/Committed revision (\d+)\./)[1]
  else
    puts "Nothing to commit"
  end
end
commit_command(message) click to toggle source
# File lib/rake_commit/svn.rb, line 27
def commit_command(message)
  "svn ci -m #{message.inspect}"
end
delete() click to toggle source
# File lib/rake_commit/svn.rb, line 64
def delete
  RakeCommit::Shell.backtick("svn st").split("\n").each do |line|
    if line[0,1] == "!"
      file = line[7..-1].strip
      RakeCommit::Shell.backtick "svn up #{file.inspect} && svn rm #{file.inspect}"
      puts %[removed #{file}]
    end
  end
end
files_to_check_in?() click to toggle source
# File lib/rake_commit/svn.rb, line 31
def files_to_check_in?
  RakeCommit::Shell.backtick("svn st --ignore-externals").split("\n").reject {|line| line[0,1] == "X"}.any?
end
new_file?(line) click to toggle source
# File lib/rake_commit/svn.rb, line 56
def new_file?(line)
  line[0,1] == "?"
end
revert_all() click to toggle source
# File lib/rake_commit/svn.rb, line 74
def revert_all
  RakeCommit::Shell.system "svn revert -R ."
  RakeCommit::Shell.backtick("svn st").split("\n").each do |line|
    next unless line[0,1] == '?'
    filename = line[1..-1].strip
    puts "removed #{filename}"
    FileUtils.rm_r filename
  end
end
status() click to toggle source
# File lib/rake_commit/svn.rb, line 35
def status
  RakeCommit::Shell.system "svn st"
end
svn_conflict_file?(line) click to toggle source
# File lib/rake_commit/svn.rb, line 60
def svn_conflict_file?(line)
  line =~ /\.r\d+$/ || line =~ /\.mine$/
end
up() click to toggle source
# File lib/rake_commit/svn.rb, line 39
def up
  output = RakeCommit::Shell.backtick "svn up"
  puts output
  output.split("\n").each do |line|
    raise "SVN conflict detected. Please resolve conflicts before proceeding." if line[0,1] == "C"
  end
end