Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Updates to build locators (e.g. "number=1.0.0.9999,branch:(default:any)") #44

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions TeamCitySharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamCitySharp.IntegrationTe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamCitySharp", "src\TeamCitySharp\TeamCitySharp.csproj", "{87598714-132F-478E-866E-8C1AF3E83057}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamCitySharp.UnitTests", "src\Tests\TeamCitySharp.UnitTests\TeamCitySharp.UnitTests.csproj", "{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -37,11 +39,24 @@ Global
{87598714-132F-478E-866E-8C1AF3E83057}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{87598714-132F-478E-866E-8C1AF3E83057}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{87598714-132F-478E-866E-8C1AF3E83057}.Release|x86.ActiveCfg = Release|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Debug|x86.ActiveCfg = Debug|x86
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Debug|x86.Build.0 = Debug|x86
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Release|Any CPU.Build.0 = Release|Any CPU
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Release|Mixed Platforms.ActiveCfg = Release|x86
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Release|Mixed Platforms.Build.0 = Release|x86
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Release|x86.ActiveCfg = Release|x86
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BA409A09-CC7B-4A71-A3D4-FE27234A721B} = {263F35DD-20C1-4209-B121-E962C9328C70}
{10D2336D-4C01-4580-ADEB-2DD4B1E15CFA} = {263F35DD-20C1-4209-B121-E962C9328C70}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion src/TeamCitySharp/ActionTypes/Builds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal Builds(TeamCityCaller caller)
_caller = caller;
}

public List<Build> ByBuildLocator(BuildLocator locator)
public List<Build> ByBuildLocator(IBuildLocator locator)
{
var buildWrapper = _caller.GetFormat<BuildWrapper>("/app/rest/builds?locator={0}", locator);
if (int.Parse(buildWrapper.Count) > 0)
Expand Down
2 changes: 1 addition & 1 deletion src/TeamCitySharp/ActionTypes/IBuilds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IBuilds
List<Build> ByBuildConfigId(string buildConfigId);
List<Build> ByConfigIdAndTag(string buildConfigId, string tag);
List<Build> ByUserName(string userName);
List<Build> ByBuildLocator(BuildLocator locator);
List<Build> ByBuildLocator(IBuildLocator locator);
List<Build> AllSinceDate(DateTime date);
List<Build> AllBuildsOfStatusSinceDate(DateTime date, BuildStatus buildStatus);
List<Build> NonSuccessfulBuildsForUser(string userName);
Expand Down
16 changes: 16 additions & 0 deletions src/TeamCitySharp/Locators/BranchLocatorFlag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TeamCitySharp.Locators
{

public enum BranchLocatorFlag
{
True,
False,
Any
}

}
8 changes: 1 addition & 7 deletions src/TeamCitySharp/Locators/BuildLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@

namespace TeamCitySharp.Locators
{
public enum BuildStatus
{
SUCCESS,
FAILURE,
ERROR
}
public class BuildLocator
public class BuildLocator : IBuildLocator
{
public static BuildLocator WithId(long id)
{
Expand Down
16 changes: 16 additions & 0 deletions src/TeamCitySharp/Locators/BuildStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TeamCitySharp.Locators
{

public enum BuildStatus
{
SUCCESS,
FAILURE,
ERROR
}

}
2 changes: 1 addition & 1 deletion src/TeamCitySharp/Locators/BuildTypeLocator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TeamCitySharp.Locators
{
public class BuildTypeLocator
public class BuildTypeLocator : IBuildTypeLocator
{
public static BuildTypeLocator WithId(string id)
{
Expand Down
121 changes: 121 additions & 0 deletions src/TeamCitySharp/Locators/FluidBranchLocator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using TeamCitySharp.Locators;

namespace TeamCitySharp.Locators
{

public sealed class FluidBranchLocator : IBranchLocator
{

#region Constructors

public FluidBranchLocator()
: base()
{
}

#endregion

#region Properties

public string Name
{
get;
private set;
}

public BranchLocatorFlag? Default
{
get;
private set;
}

public BranchLocatorFlag? Unspecified
{
get;
private set;
}

public BranchLocatorFlag? Branched
{
get;
private set;
}

#endregion

#region Fluid Methods

public static FluidBranchLocator WithDimensions(string name = null, BranchLocatorFlag? @default = null, BranchLocatorFlag? unspecified = null, BranchLocatorFlag? branched = null)
{
var locator = new FluidBranchLocator();
locator.Name = name;
locator.Default = @default;
locator.Unspecified = unspecified;
locator.Branched = branched;
return locator;
}

public FluidBranchLocator WithName(string name)
{
var clone = (FluidBranchLocator)this.MemberwiseClone();
clone.Name = name;
return clone;
}

public FluidBranchLocator WithDefault(BranchLocatorFlag? @default)
{
var clone = (FluidBranchLocator)this.MemberwiseClone();
clone.Default = @default;
return clone;
}

public FluidBranchLocator WithUnspecified(BranchLocatorFlag? unspecified)
{
var clone = (FluidBranchLocator)this.MemberwiseClone();
clone.Unspecified = unspecified;
return clone;
}

public FluidBranchLocator WithBranched(BranchLocatorFlag? branched)
{
var clone = (FluidBranchLocator)this.MemberwiseClone();
clone.Branched = branched;
return clone;
}

#endregion

public override string ToString()
{

var dimensions = new List<string>();

if (!string.IsNullOrEmpty(this.Name))
{
dimensions.Add("name:" + this.Name);
}

if (this.Default.HasValue)
{
dimensions.Add("default:" + this.Default.ToString().ToLowerInvariant());
}

if (this.Unspecified.HasValue)
{
dimensions.Add("unspecified:" + this.Unspecified.ToString().ToLowerInvariant());
}

if (this.Branched.HasValue)
{
dimensions.Add("branched:" + this.Branched.ToString().ToLowerInvariant());
}

return string.Join(",", dimensions.ToArray());

}

}

}
Loading