Skip to content
Merged
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
5 changes: 0 additions & 5 deletions GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public override bool CanApplyToCurrentContext()
throw new NotImplementedException();
}

public override void PerformPreProcessingSteps(string gitDirectory, bool noFetch)
{
throw new NotImplementedException();
}

public override string GenerateSetVersionMessage(string versionToUseForBuildNumber)
{
return versionToUseForBuildNumber;
Expand Down
3 changes: 1 addition & 2 deletions GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public class ContinuaCiTests
[Test]
public void GenerateBuildVersion()
{
var authentication = new Authentication();
var versionBuilder = new ContinuaCi(authentication);
var versionBuilder = new ContinuaCi();
var continuaCiVersion = versionBuilder.GenerateSetVersionMessage("0.0.0-Beta4.7");
Assert.AreEqual("@@continua[setBuildVersion value='0.0.0-Beta4.7']", continuaCiVersion);
}
Expand Down
9 changes: 3 additions & 6 deletions GitVersionCore.Tests/BuildServers/MyGetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ public class MyGetTests
[Test]
public void Develop_branch()
{
var authentication = new Authentication();
var versionBuilder = new MyGet(authentication);
var versionBuilder = new MyGet();
var message = versionBuilder.GenerateSetVersionMessage("0.0.0-Unstable4");
Assert.AreEqual(null, message);
}

[Test]
public void EscapeValues()
{
var authentication = new Authentication();
var versionBuilder = new MyGet(authentication);
var versionBuilder = new MyGet();
var message = versionBuilder.GenerateSetParameterMessage("Foo", "0.8.0-unstable568 Branch:'develop' Sha:'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb'");
Assert.AreEqual("##myget[setParameter name='GitVersion.Foo' value='0.8.0-unstable568 Branch:|'develop|' Sha:|'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb|'']", message[0]);
}

[Test]
public void BuildNumber()
{
var authentication = new Authentication();
var versionBuilder = new MyGet(authentication);
var versionBuilder = new MyGet();
var message = versionBuilder.GenerateSetParameterMessage("LegacySemVerPadded", "0.8.0-unstable568");
Assert.AreEqual("##myget[buildNumber '0.8.0-unstable568']", message[1]);
}
Expand Down
6 changes: 2 additions & 4 deletions GitVersionCore.Tests/BuildServers/TeamCityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ public class TeamCityTests
[Test]
public void Develop_branch()
{
var authentication = new Authentication();
var versionBuilder = new TeamCity(authentication);
var versionBuilder = new TeamCity();
var tcVersion = versionBuilder.GenerateSetVersionMessage("0.0.0-Unstable4");
Assert.AreEqual("##teamcity[buildNumber '0.0.0-Unstable4']", tcVersion);
}

[Test]
public void EscapeValues()
{
var authentication = new Authentication();
var versionBuilder = new TeamCity(authentication);
var versionBuilder = new TeamCity();
var tcVersion = versionBuilder.GenerateSetParameterMessage("Foo", "0.8.0-unstable568 Branch:'develop' Sha:'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb'");
Assert.AreEqual("##teamcity[setParameter name='GitVersion.Foo' value='0.8.0-unstable568 Branch:|'develop|' Sha:|'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb|'']", tcVersion[0]);
Assert.AreEqual("##teamcity[setParameter name='system.GitVersion.Foo' value='0.8.0-unstable568 Branch:|'develop|' Sha:|'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb|'']", tcVersion[1]);
Expand Down
18 changes: 9 additions & 9 deletions GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
[TestFixture]
public class ConfigProviderTests
{
string gitDirectory;
string repoPath;
IFileSystem fileSystem;

[SetUp]
public void Setup()
{
fileSystem = new TestFileSystem();
gitDirectory = "c:\\MyGitRepo\\.git";
repoPath = "c:\\MyGitRepo";
}

[Test]
Expand All @@ -41,7 +41,7 @@ public void CanReadDocument()
";
SetupConfigFileContent(text);

var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinor);
config.NextVersion.ShouldBe("2.0.0");
config.TagPrefix.ShouldBe("[vV|version-]");
Expand All @@ -61,7 +61,7 @@ public void CanReadOldDocument()
release-branch-tag: rc
";
SetupConfigFileContent(text);
var error = Should.Throw<OldConfigurationException>(() => ConfigurationProvider.Provide(gitDirectory, fileSystem));
var error = Should.Throw<OldConfigurationException>(() => ConfigurationProvider.Provide(repoPath, fileSystem));
error.Message.ShouldContainWithoutWhitespace(@"GitVersionConfig.yaml contains old configuration, please fix the following errors:
assemblyVersioningScheme has been replaced by assembly-versioning-scheme
develop-branch-tag has been replaced by branch specific configuration.See https://github.com/ParticularLabs/GitVersion/wiki/Branch-Specific-Configuration
Expand All @@ -79,7 +79,7 @@ public void OverwritesDefaultsWithProvidedConfig()
tag: dev";
SetupConfigFileContent(text);
var defaultConfig = new Config();
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.NextVersion.ShouldBe("2.0.0");
config.AssemblyVersioningScheme.ShouldBe(defaultConfig.AssemblyVersioningScheme);
Expand All @@ -97,7 +97,7 @@ public void CanProvideConfigForNewBranch()
bug[/-]:
tag: bugfix";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.Branches["bug[/-]"].Tag.ShouldBe("bugfix");
}
Expand All @@ -106,7 +106,7 @@ public void CanProvideConfigForNewBranch()
[MethodImpl(MethodImplOptions.NoInlining)]
public void CanWriteOutEffectiveConfiguration()
{
var config = ConfigurationProvider.GetEffectiveConfigAsString(gitDirectory, fileSystem);
var config = ConfigurationProvider.GetEffectiveConfigAsString(repoPath, fileSystem);

Approvals.Verify(config);
}
Expand All @@ -116,7 +116,7 @@ public void CanReadDefaultDocument()
{
const string text = "";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
config.Branches["develop"].Tag.ShouldBe("unstable");
config.Branches["release[/-]"].Tag.ShouldBe("beta");
Expand Down Expand Up @@ -156,6 +156,6 @@ public void VerifyAliases()

void SetupConfigFileContent(string text)
{
fileSystem.WriteAllText(Path.Combine(Directory.GetParent(gitDirectory).FullName, "GitVersionConfig.yaml"), text);
fileSystem.WriteAllText(Path.Combine(repoPath, "GitVersionConfig.yaml"), text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"BranchName":"feature1",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0004",
"NuGetVersion":"1.2.3-unstable0004"
"NuGetVersion":"1.2.3-unstable0004",
"CommitDate":"2014-03-06"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0004",
"NuGetVersion":"1.2.3-unstable0004"
"NuGetVersion":"1.2.3-unstable0004",
"CommitDate":"2014-03-06"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3",
"NuGetVersion":"1.2.3"
"NuGetVersion":"1.2.3",
"CommitDate":"2014-03-06"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0005",
"NuGetVersion":"1.2.3-unstable0005"
"NuGetVersion":"1.2.3-unstable0005",
"CommitDate":"2014-03-06"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-ci0005",
"NuGetVersion":"1.2.3-ci0005"
"NuGetVersion":"1.2.3-ci0005",
"CommitDate":"2014-03-06"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"BranchName":"",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3",
"NuGetVersion":"1.2.3"
"NuGetVersion":"1.2.3",
"CommitDate":"2014-03-06"
}
17 changes: 0 additions & 17 deletions GitVersionCore/BuildServers/AppVeyor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,11 @@

public class AppVeyor : BuildServerBase
{
Authentication authentication;

public AppVeyor(Authentication authentication)
{
this.authentication = authentication;
}

public override bool CanApplyToCurrentContext()
{
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPVEYOR"));
}

public override void PerformPreProcessingSteps(string gitDirectory, bool noFetch)
{
if (string.IsNullOrEmpty(gitDirectory))
{
throw new WarningException("Failed to find .git directory on agent.");
}

GitHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch);
}

public override string GenerateSetVersionMessage(string versionToUseForBuildNumber)
{
var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER");
Expand Down
1 change: 0 additions & 1 deletion GitVersionCore/BuildServers/BuildServerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
public abstract class BuildServerBase : IBuildServer
{
public abstract bool CanApplyToCurrentContext();
public abstract void PerformPreProcessingSteps(string gitDirectory, bool noFetch);
public abstract string GenerateSetVersionMessage(string versionToUseForBuildNumber);
public abstract string[] GenerateSetParameterMessage(string name, string value);

Expand Down
31 changes: 7 additions & 24 deletions GitVersionCore/BuildServers/BuildServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,16 @@

public static class BuildServerList
{
static List<IBuildServer> BuildServers;

public static Func<Authentication, IEnumerable<IBuildServer>> Selector = arguments => DefaultSelector(arguments);

public static void ResetSelector()
{
Selector = DefaultSelector;
}

public static IEnumerable<IBuildServer> GetApplicableBuildServers(Authentication authentication)
static List<IBuildServer> BuildServers = new List<IBuildServer>
{
return Selector(authentication);
}
new ContinuaCi(),
new TeamCity(),
new AppVeyor(),
new MyGet()
};

static IEnumerable<IBuildServer> DefaultSelector(Authentication authentication)
public static IEnumerable<IBuildServer> GetApplicableBuildServers()
{
if (BuildServers == null)
{
BuildServers = new List<IBuildServer>
{
new ContinuaCi(authentication),
new TeamCity(authentication),
new AppVeyor(authentication),
new MyGet(authentication)
};
}

var buildServices = new List<IBuildServer>();

foreach (var buildServer in BuildServers)
Expand Down
17 changes: 0 additions & 17 deletions GitVersionCore/BuildServers/ContinuaCi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

public class ContinuaCi : BuildServerBase
{
Authentication authentication;

public ContinuaCi(Authentication authentication)
{
this.authentication = authentication;
}

public override bool CanApplyToCurrentContext()
{
const string KeyName = @"Software\VSoft Technologies\Continua CI Agent";
Expand All @@ -28,16 +21,6 @@ public override bool CanApplyToCurrentContext()
return false;
}

public override void PerformPreProcessingSteps(string gitDirectory, bool noFetch)
{
if (string.IsNullOrEmpty(gitDirectory))
{
throw new WarningException("Failed to find .git directory on agent");
}

GitHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch);
}

public override string[] GenerateSetParameterMessage(string name, string value)
{
return new[]
Expand Down
1 change: 0 additions & 1 deletion GitVersionCore/BuildServers/IBuildServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
public interface IBuildServer
{
bool CanApplyToCurrentContext();
void PerformPreProcessingSteps(string gitDirectory, bool noFetch);
string GenerateSetVersionMessage(string versionToUseForBuildNumber);
string[] GenerateSetParameterMessage(string name, string value);

Expand Down
17 changes: 0 additions & 17 deletions GitVersionCore/BuildServers/MyGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

public class MyGet : BuildServerBase
{
Authentication authentication;

public MyGet(Authentication authentication)
{
this.authentication = authentication;
}

public override bool CanApplyToCurrentContext()
{
var buildRunner = Environment.GetEnvironmentVariable("BuildRunner");
Expand All @@ -20,16 +13,6 @@ public override bool CanApplyToCurrentContext()
&& buildRunner.Equals("MyGet", StringComparison.InvariantCultureIgnoreCase);
}

public override void PerformPreProcessingSteps(string gitDirectory, bool noFetch)
{
if (string.IsNullOrEmpty(gitDirectory))
{
throw new WarningException("Failed to find .git directory on agent.");
}

GitHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch);
}

public override string[] GenerateSetParameterMessage(string name, string value)
{
var messages = new List<string>
Expand Down
17 changes: 0 additions & 17 deletions GitVersionCore/BuildServers/TeamCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,11 @@

public class TeamCity : BuildServerBase
{
Authentication authentication;

public TeamCity(Authentication authentication)
{
this.authentication = authentication;
}

public override bool CanApplyToCurrentContext()
{
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION"));
}

public override void PerformPreProcessingSteps(string gitDirectory, bool noFetch)
{
if (string.IsNullOrEmpty(gitDirectory))
{
throw new WarningException("Failed to find .git directory on agent. Please make sure agent checkout mode is enabled for you VCS roots - http://confluence.jetbrains.com/display/TCD8/VCS+Checkout+Mode");
}

GitHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch);
}

public override string[] GenerateSetParameterMessage(string name, string value)
{
return new[]
Expand Down
Loading