Skip to content

Commit

Permalink
Automatically merge changes from branch to trunk if PATH_TO_TRUNK_WOR…
Browse files Browse the repository at this point in the history
…KING_COPY is set
  • Loading branch information
pgr0ss committed Feb 20, 2009
1 parent aa597bc commit 66a3a48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tasks/commit.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ task :commit => "svn:st" do
if files_to_check_in?
commit_message = CommitMessage.new.prompt
Rake::Task[:pc].invoke
sh "#{commit_command(commit_message)}" if ok_to_check_in?

if ok_to_check_in?
output = sh_with_output "#{commit_command(commit_message)}"
revision = output.match(/Committed revision (\d+)\./)[1]
merge_to_trunk(revision) if `svn info`.include?("branches") && self.class.const_defined?(:PATH_TO_TRUNK_WORKING_COPY)
end
else
puts "Nothing to commit"
end
Expand All @@ -39,4 +44,12 @@ def are_you_sure?(message)
input = Readline.readline("Are you sure you want to check in? (y/n): ")
end
return input.strip.downcase[0,1] == "y"
end
end

def sh_with_output(command)
puts command
output = `#{command}`
puts output
raise unless $?.success?
output
end
6 changes: 6 additions & 0 deletions tasks/svn.rake
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,11 @@ namespace :svn do
rm_r filename
end
end

def merge_to_trunk(revision)
puts "Merging changes into trunk. Don't forget to check these in."
sh "svn up #{PATH_TO_TRUNK_WORKING_COPY.inspect}"
sh "svn merge -c #{revision} . #{PATH_TO_TRUNK_WORKING_COPY.inspect}"
end

end

0 comments on commit 66a3a48

Please sign in to comment.