mikeclayton/TeamCitySharp — pull request #1 by mikeclayton (2014-01-03 20:08:38+00:00)
Title: Added branch locators to find builds on non-default (master) branch

Resubmission of pull request #44 on a separate feature branch (last pull request was on master) and conflicts resolved with latest upstream master...

At the moment if you use a BuildLocator to find a build by id or number you can't also specify additional dimensions like "branch:(default:any)" to look in non-default branches. This was causing me a problem so I've made some changes to allow locating builds by id or number and dimensions at the same time:

+ a new BranchLocator class that wraps the "branch locator" spec in the TeamCity REST API - e.g. "(name:name,default:true/false/any,unspecified:true/false/any,branched:true/false/any)"

+ allow build locators to specify dimensions in addition to id or number - e.g. "number:1.0.0.9999,buildType:(name:My CI Build),status:SUCCESS,branch:(default:any)"

+ additional Locator classes that implement Fluid methods for each property. No more BuildLocator::WithDimensions($null, $null, $null, $null, $null, $null, $null, 100, 50, $null, $null, $null, $null) in PowerShell to specify maxResults and startIndex - just use (new-object FluidBuildLocator).WithMaxResults(100).WithStartIndex(50) instead.

+ added a load of unit tests to check string generation for Locators.

Example (in PowerShell):

$branchLocator = (new-object TeamCitySharp.Locators.FluidBranchLocator).WithDefault("Any");

$buildTypeLocator = [TeamCitySharp.Locators.FluidBuildTypeLocator]::WithName($buildTypeName);

$buildLocator = [TeamCitySharp.Locators.FluidBuildLocator]::WithNumber($buildNumber).WithBuildType(
$buildTypeLocator).WithBranch($branchLocator).WithStatus("SUCCESS");

$builds = $tcClient.Builds.ByBuildLocator($buildLocator);