Class: RakeCommit::Svn
- Inherits:
-
Object
- Object
- RakeCommit::Svn
- Defined in:
- lib/rake_commit/svn.rb
Instance Method Summary collapse
- #add ⇒ Object
- #commit ⇒ Object
- #commit_command(message) ⇒ Object
- #delete ⇒ Object
- #files_to_check_in? ⇒ Boolean
-
#initialize(prompt_exclusions = [], precommit = nil) ⇒ Svn
constructor
A new instance of Svn.
- #new_file?(line) ⇒ Boolean
- #revert_all ⇒ Object
- #status ⇒ Object
- #svn_conflict_file?(line) ⇒ Boolean
- #up ⇒ Object
Constructor Details
#initialize(prompt_exclusions = [], precommit = nil) ⇒ Svn
Returns a new instance of Svn.
6 7 8 9 |
# File 'lib/rake_commit/svn.rb', line 6 def initialize(prompt_exclusions = [], precommit = nil) @prompt_exclusions = prompt_exclusions @precommit = precommit end |
Instance Method Details
#add ⇒ Object
47 48 49 50 51 52 53 54 |
# 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 ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rake_commit/svn.rb', line 11 def commit if files_to_check_in? = RakeCommit::CommitMessage.new(@prompt_exclusions). RakeCommit::Shell.system(@precommit) unless @precommit.nil? add delete up RakeCommit::Shell.system "rake" output = RakeCommit::Shell.backtick "#{commit_command()}" puts output revision = output.match(/Committed revision (\d+)\./)[1] else puts "Nothing to commit" end end |
#commit_command(message) ⇒ Object
27 28 29 |
# File 'lib/rake_commit/svn.rb', line 27 def commit_command() "svn ci -m #{.inspect}" end |
#delete ⇒ Object
64 65 66 67 68 69 70 71 72 |
# 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? ⇒ Boolean
31 32 33 |
# 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) ⇒ Boolean
56 57 58 |
# File 'lib/rake_commit/svn.rb', line 56 def new_file?(line) line[0,1] == "?" end |
#revert_all ⇒ Object
74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
35 36 37 |
# File 'lib/rake_commit/svn.rb', line 35 def status RakeCommit::Shell.system "svn st" end |
#svn_conflict_file?(line) ⇒ Boolean
60 61 62 |
# File 'lib/rake_commit/svn.rb', line 60 def svn_conflict_file?(line) line =~ /\.r\d+$/ || line =~ /\.mine$/ end |
#up ⇒ Object
39 40 41 42 43 44 45 |
# 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 |