Skip to content

Initial refactoring of Variable provider and the way variables are gener... #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 30, 2014
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
28 changes: 13 additions & 15 deletions AcceptanceTests/AcceptanceTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@
<Reference Include="LibGit2Sharp">
<HintPath>..\packages\LibGit2Sharp.0.16.0.0\lib\net35\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Shouldly">
<HintPath>..\packages\Shouldly.2.1.1\lib\net40\Shouldly.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TestStack.BDDfy, Version=3.19.1.0, Culture=neutral, PublicKeyToken=a357057d05a879bd, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\TestStack.BDDfy.3.19.1\lib\NET40\TestStack.BDDfy.dll</HintPath>
</Reference>
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
Expand All @@ -59,29 +58,27 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EmptyRepositorySpecification.cs" />
<Compile Include="ExecArgSpecification.cs" />
<Compile Include="ExecCmdLineArgumentTest.cs" />
<Compile Include="GitFlow\DevelopScenarios.cs" />
<Compile Include="GitFlow\UncycloScenarios.cs" />
<Compile Include="Helpers\Constants.cs" />
<Compile Include="PullRequestInTeamCityTest.cs" />
<Compile Include="EmptyRepositoryFixture.cs" />
<Compile Include="Helpers\ExecutionResults.cs" />
<Compile Include="Helpers\GitHelper.cs" />
<Compile Include="Helpers\GitVersionHelper.cs" />
<Compile Include="Helpers\IPostTestDirectoryRemover.cs" />
<Compile Include="Helpers\PathHelper.cs" />
<Compile Include="Helpers\ProcessHelper.cs" />
<Compile Include="Helpers\Scrubbers.cs" />
<Compile Include="NoTagsInRepositorySpecification.cs" />
<Compile Include="NoTagsInRepositoryWithNextVersionTxtSpecification.cs" />
<Compile Include="ProjArgSpecification.cs" />
<Compile Include="GitHubFlow\MasterTests.cs" />
<Compile Include="MsBuildProjectArgTest.cs" />
<Compile Include="Properties\ApprovalTestsConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="PullRequestsFixture.cs" />
<Compile Include="RepositoryFixture.cs" />
<Compile Include="TagFollowedByCommitsWithApplicableNextVersionTxtSpecification.cs" />
<Compile Include="TagFollowedByCommitsWithNoNextVersionTxtSpecification.cs" />
<Compile Include="TagFollowedByCommitsWithRedundantNextVersionTxtSpecification.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand All @@ -100,6 +97,7 @@
<Name>GitVersion</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

namespace GitHubFlowVersion.AcceptanceTests
{
public class RepositoryFixture : IDisposable
public class EmptyRepositoryFixture : IDisposable
{
public readonly string RepositoryPath;
public readonly Repository Repository;

public RepositoryFixture()
public EmptyRepositoryFixture()
{
RepositoryPath = PathHelper.GetTempPath();
Repository.Init(RepositoryPath);
Expand All @@ -19,19 +19,29 @@ public RepositoryFixture()
Repository = new Repository(RepositoryPath);
Repository.Config.Set("user.name", "Test");
Repository.Config.Set("user.email", "[email protected]");

var randomFile = Path.Combine(Repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
File.WriteAllText(randomFile, string.Empty);
Repository.Index.Stage(randomFile);
Repository.Commit("Initial Commit", new Signature("Test User", "[email protected]", DateTimeOffset.UtcNow));
}

public void Dispose()
{
Repository.Dispose();
try
{
Directory.Delete(RepositoryPath, true);
//Directory.Delete(RepositoryPath, true);
}
catch (Exception e)
{
Console.WriteLine("Failed to clean up repository path at {0}. Received exception: {1}", RepositoryPath, e.Message);
}
}

public ExecutionResults ExecuteGitVersion()
{
return GitVersionHelper.ExecuteIn(RepositoryPath);
}
}
}
44 changes: 0 additions & 44 deletions AcceptanceTests/EmptyRepositorySpecification.cs

This file was deleted.

43 changes: 0 additions & 43 deletions AcceptanceTests/ExecArgSpecification.cs

This file was deleted.

32 changes: 32 additions & 0 deletions AcceptanceTests/ExecCmdLineArgumentTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

namespace GitHubFlowVersion.AcceptanceTests
{
using global::AcceptanceTests.Properties;
using System.IO;
using Helpers;
using Shouldly;
using Xunit;

public class ExecCmdLineArgumentTest
{
private const string MsBuild = @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
private const string TaggedVersion = "1.2.3";

[Fact]
public void RunExecViaCommandLine()
{
using (var fixture = new EmptyRepositoryFixture())
{
fixture.Repository.MakeATaggedCommit(TaggedVersion);
fixture.Repository.MakeACommit();

var buildFile = Path.Combine(fixture.RepositoryPath, "TestBuildFile.proj");
File.WriteAllBytes(buildFile, Resources.TestBuildFile);
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, MsBuild, "TestBuildFile.proj /target:OutputResults");

result.ExitCode.ShouldBe(0);
result.Log.ShouldContain("GitVersion_FullSemVer: 1.2.4+1");
}
}
}
}
26 changes: 26 additions & 0 deletions AcceptanceTests/GitFlow/DevelopScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace AcceptanceTests.GitFlow
{
using GitHubFlowVersion.AcceptanceTests;
using GitHubFlowVersion.AcceptanceTests.Helpers;
using GitVersion;
using LibGit2Sharp;
using Shouldly;
using Xunit;

public class DevelopScenarios
{
[Fact]
public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
{
using (var fixture = new EmptyRepositoryFixture())
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();

var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);

result.OutputVariables[VariableProvider.SemVer].ShouldBe("1.1.0.1-unstable");
}
}
}
}
97 changes: 97 additions & 0 deletions AcceptanceTests/GitFlow/UncycloScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
namespace AcceptanceTests.GitFlow
{
using GitHubFlowVersion.AcceptanceTests;
using GitHubFlowVersion.AcceptanceTests.Helpers;
using GitVersion;
using LibGit2Sharp;
using Shouldly;
using Xunit;

public class UncycloScenarios
{
/// <summary>
/// https://github.com/Particular/GitVersion/wiki/GitFlowExamples#minor-release
/// </summary>
/* These will be slightly out of sync because we need to make a commit to force a merge commit
participant featureAbc
participant develop
participant release-1.3.0
master -> master: tag 1.2.0
master -> develop: merge
note over develop: 1.3.0.0-unstable
develop -> featureAbc: branch
note over featureAbc: Open Pull Request #2
note over featureAbc: 1.3.0-PullRequest.2+0
featureAbc -> featureAbc: commit
note over featureAbc: 1.3.0-PullRequest.2+1
featureAbc -> develop: merge --no-ff
note over develop: 1.3.0.3-unstable
develop -> release-1.3.0: branch
note over release-1.3.0: 1.3.0-beta.1+0
develop -> develop: commit
note over develop: 1.3.0.4-unstable
release-1.3.0 -> release-1.3.0: commit
note over release-1.3.0: 1.3.0-beta.1+1
release-1.3.0 -> release-1.3.0: tag 1.3.0-beta.1
note over release-1.3.0: 1.3.0-beta.2+1
release-1.3.0 -> master: merge and tag master 1.3.0
note over master: 1.3.0
release-1.3.0 -> develop: merge --no-ff
note over develop: 1.4.0.2-unstable
*/
[Fact]
public void MinorReleaseExample()
{
using (var fixture = new EmptyRepositoryFixture())
{
fixture.Repository.MakeATaggedCommit("1.2.0");

// Branch to develop
fixture.Repository.CreateBranch("develop").Checkout();
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0.0-unstable");

// Open Pull Request
fixture.Repository.CreateBranch("pull/2/merge").Checkout();
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-PullRequest.2+0");
fixture.Repository.MakeACommit();
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-PullRequest.2+1");

// Merge into develop
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("pull/2/merge", Constants.SignatureNow());
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0.3-unstable");

// Create release branch
fixture.Repository.CreateBranch("release-1.3.0").Checkout();
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-beta.1+0");

// Make another commit on develop
fixture.Repository.Checkout("develop");
fixture.Repository.MakeACommit();
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0.4-unstable");

// Make a commit to release-1.3.0
fixture.Repository.Checkout("release-1.3.0");
fixture.Repository.MakeACommit();
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-beta.1+1");

// Apply beta.0 tag
fixture.Repository.ApplyTag("1.3.0-beta.1");
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-beta.2+1");

// Merge release branch to master
fixture.Repository.Checkout("master");
// No way to force a merge commit in libgit2, so commit before merge
fixture.Repository.MakeACommit();
fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0");
fixture.Repository.ApplyTag("1.3.0");

// Verify develop version
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.4.0.3-unstable");
}
}
}
}
Loading