Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I automatically svn merge when automated tests pass?

After each commit into 'trunk', we automatically run a bunch of tests against trunk. When those tests pass, I'd like an automated merge into a branch called 'tests-passed'. When the tests fail, no merge should happen, but once the problem is fixed on 'trunk' at the next or a later commit, all the changes should be merged.

The point is to have a branch that has the same content as trunk, but that is just a tad more sane than 'trunk' because at least the automated tests have passed.

I have a script that tries to do that manually but it's a hack using custom properties that doesn't always work correctly -- as I just found out. How do I best make Subversion do this?

like image 699
Johannes Ernst Avatar asked Jan 06 '11 19:01

Johannes Ernst


People also ask

What is a svn Sync merge?

This basic syntax— svn merge URL —tells Subversion to merge all changes which have not been previously merged from the URL to the current working directory (which is typically the root of your working copy).

How do I merge revisions in svn?

To merge a range of revisions, use svn merge -r start:end from to where start and end are revision IDs. This will merge all revisions starting at start+1 up to and INCLUDING end . Note: it will NOT include the first revision (ex: -r3:45 will merge 4 through 45).


2 Answers

Run these commands at the root of a working copy of tests-passed whenever you have determined that a new trunk revision <somerev> has passed the tests:

svn update
svn merge http://example.com/svn/myproject/trunk -r 0:<somerev>
svn commit -m "merged trunk revisions up to <somerev> into tests-passed"

Whenever you use the merge command, SVN will record the merges in the svn:mergeinfo property. So the above command should automatically determine which revisions in the range 0:<somerev> are eligible for merging, excluding any merges that have already been done.

Like you said in a comment, conflicts are not expected. But sometimes I've seen unexpected conflicts occur anyway when merging a range of SVN revisions containing renames. To get rid of these conflicts, you can use the --accept theirs-full option with the merge command to always accept the trunk state.

like image 133
Wim Coenen Avatar answered Sep 30 '22 12:09

Wim Coenen


You can use a Continuous Integration Tool for that. One pretty popular: Hudson

http://hudson-ci.org/

You can script that kind of behaviour there.

like image 35
Nerian Avatar answered Sep 30 '22 14:09

Nerian