ccnet/CruiseControl.NET — pull request #197 by kennethahn (2013-09-06 12:58:27+00:00)
Title: Removed unintended change to from.SourceControlData

Fixed bug where MultiSourceControl.GetModifications would leave the
from.SourceControlData changed, so the following call to
GetModifications would result in Modifications being erroneously
reported.

--- Full description --
While debugging some problems with CCnet and git I stumbled upon something that looks like unintended behavior, but I'm not sure if it's bad configuration or my expectations that are wrong.

I started out with the demo ccnet.config and added a multi source control block with two git repositories.
The repos are made for testing, so each one has just one text file with 2 commits. They are located locally on the same drive as CCnet is running from.
My "build" is just the ping action from the demo script.

The behavior I'm seeing is that at first integration the repos are cloned, thus there are modifications, and the build is triggered.
Second integration run there are no modifications - which is expected.
But the third run, CCnet finds that there are modifications, so the build is triggered.
From here on, it runs a steady rhythm - every other integration, CCnet sees changes and triggers the build (and the repositories are not changed).

If I have just one sourcecontrol of type git, then everything works as expected - build is only triggered when I change the repository.

As far as I can see, the method MultiSourceControl.GetModifications(IIntegrationResult from, IIntegrationResult to) modified the from.SourceControlData list, so every other time it has only 1 of the 2 actual source-control-objects, and that triggers the build. I have a tiny patch that fixes the issue and doesn't break any unit tests.

To reproduce, create two repos as
mkdir test1; cd test1; git init; echo 123 > file.txt; git commit -m "first"; echo 321 >> file.txt; git commit -m "second"
mkdir test2; cd test2; git init; echo 123 > file.txt; git commit -m "first"; echo 321 >> file.txt; git commit -m "second"

ccnet config:

BuildArtifacts

C:\repo\Test1
master
true
$(git.exe)
Test1

C:\repo\Test2
master
true
$(git.exe)
Test2

ping.exe
localhost
15
Pinging a server