Automatically merge changes from branch to trunk

On my current project, we release code often. As a result, we usually
have at least one active branch along with the trunk. When bugs arise in
production, we fix them in the branch and then merge them into the
trunk. This constant merging was becoming a pain, so we automated it
with a rake task that looks like:

desc 'merge changes from branch to trunk'
task :'svn:merge_to_trunk' do
  if %x[svn info].include? "branches"
    puts "Merging changes into trunk.  Don't forget to check these in."
    system "svn diff | patch -p0 -d /path/to/truck/checkout"
  end
end

This task first checks to see if we are on the branch. If our checkout
is from the trunk, it does nothing. Then, it does a “svn diff” and pipes
that into patch, which applies the diff to the local working copy for
the trunk.

We added this task as a dependency on our commit task, which we run in
order to check in (see Ruby: rake
commit
). Once
we check into the branch, we switch over to the trunk working copy and
run “rake commit” again to check in the changes.

Paul Gross

Paul Gross

I'm a lead software developer in Seattle working for Braintree Payments.

Read More