Skip to content

Commit d451fa0

Browse files
committed
Merge pull request #135 from JakeGinnivan/CleaningUpVariables
Initial refactoring of Variable provider and the way variables are gener...
2 parents bc68714 + 2d50fd0 commit d451fa0

File tree

144 files changed

+1968
-2845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+1968
-2845
lines changed

AcceptanceTests/AcceptanceTests.csproj

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,16 @@
4040
<Reference Include="LibGit2Sharp">
4141
<HintPath>..\packages\LibGit2Sharp.0.16.0.0\lib\net35\LibGit2Sharp.dll</HintPath>
4242
</Reference>
43+
<Reference Include="Shouldly">
44+
<HintPath>..\packages\Shouldly.2.1.1\lib\net40\Shouldly.dll</HintPath>
45+
</Reference>
4346
<Reference Include="System" />
4447
<Reference Include="System.Core" />
4548
<Reference Include="System.Web.Extensions" />
4649
<Reference Include="System.Xml.Linq" />
4750
<Reference Include="System.Data.DataSetExtensions" />
4851
<Reference Include="System.Data" />
4952
<Reference Include="System.Xml" />
50-
<Reference Include="TestStack.BDDfy, Version=3.19.1.0, Culture=neutral, PublicKeyToken=a357057d05a879bd, processorArchitecture=MSIL">
51-
<SpecificVersion>False</SpecificVersion>
52-
<HintPath>..\packages\TestStack.BDDfy.3.19.1\lib\NET40\TestStack.BDDfy.dll</HintPath>
53-
</Reference>
5453
<Reference Include="xunit">
5554
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
5655
</Reference>
@@ -59,29 +58,27 @@
5958
</Reference>
6059
</ItemGroup>
6160
<ItemGroup>
62-
<Compile Include="EmptyRepositorySpecification.cs" />
63-
<Compile Include="ExecArgSpecification.cs" />
61+
<Compile Include="ExecCmdLineArgumentTest.cs" />
62+
<Compile Include="GitFlow\DevelopScenarios.cs" />
63+
<Compile Include="GitFlow\UncycloScenarios.cs" />
64+
<Compile Include="Helpers\Constants.cs" />
65+
<Compile Include="PullRequestInTeamCityTest.cs" />
66+
<Compile Include="EmptyRepositoryFixture.cs" />
6467
<Compile Include="Helpers\ExecutionResults.cs" />
6568
<Compile Include="Helpers\GitHelper.cs" />
6669
<Compile Include="Helpers\GitVersionHelper.cs" />
70+
<Compile Include="Helpers\IPostTestDirectoryRemover.cs" />
6771
<Compile Include="Helpers\PathHelper.cs" />
68-
<Compile Include="Helpers\ProcessHelper.cs" />
6972
<Compile Include="Helpers\Scrubbers.cs" />
70-
<Compile Include="NoTagsInRepositorySpecification.cs" />
71-
<Compile Include="NoTagsInRepositoryWithNextVersionTxtSpecification.cs" />
72-
<Compile Include="ProjArgSpecification.cs" />
73+
<Compile Include="GitHubFlow\MasterTests.cs" />
74+
<Compile Include="MsBuildProjectArgTest.cs" />
7375
<Compile Include="Properties\ApprovalTestsConfig.cs" />
7476
<Compile Include="Properties\AssemblyInfo.cs" />
7577
<Compile Include="Properties\Resources.Designer.cs">
7678
<AutoGen>True</AutoGen>
7779
<DesignTime>True</DesignTime>
7880
<DependentUpon>Resources.resx</DependentUpon>
7981
</Compile>
80-
<Compile Include="PullRequestsFixture.cs" />
81-
<Compile Include="RepositoryFixture.cs" />
82-
<Compile Include="TagFollowedByCommitsWithApplicableNextVersionTxtSpecification.cs" />
83-
<Compile Include="TagFollowedByCommitsWithNoNextVersionTxtSpecification.cs" />
84-
<Compile Include="TagFollowedByCommitsWithRedundantNextVersionTxtSpecification.cs" />
8582
</ItemGroup>
8683
<ItemGroup>
8784
<None Include="packages.config" />
@@ -100,6 +97,7 @@
10097
<Name>GitVersion</Name>
10198
</ProjectReference>
10299
</ItemGroup>
100+
<ItemGroup />
103101
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
104102
<PropertyGroup>
105103
<PostBuildEvent>

AcceptanceTests/RepositoryFixture.cs renamed to AcceptanceTests/EmptyRepositoryFixture.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
namespace GitHubFlowVersion.AcceptanceTests
77
{
8-
public class RepositoryFixture : IDisposable
8+
public class EmptyRepositoryFixture : IDisposable
99
{
1010
public readonly string RepositoryPath;
1111
public readonly Repository Repository;
1212

13-
public RepositoryFixture()
13+
public EmptyRepositoryFixture()
1414
{
1515
RepositoryPath = PathHelper.GetTempPath();
1616
Repository.Init(RepositoryPath);
@@ -19,19 +19,29 @@ public RepositoryFixture()
1919
Repository = new Repository(RepositoryPath);
2020
Repository.Config.Set("user.name", "Test");
2121
Repository.Config.Set("user.email", "[email protected]");
22+
23+
var randomFile = Path.Combine(Repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
24+
File.WriteAllText(randomFile, string.Empty);
25+
Repository.Index.Stage(randomFile);
26+
Repository.Commit("Initial Commit", new Signature("Test User", "[email protected]", DateTimeOffset.UtcNow));
2227
}
2328

2429
public void Dispose()
2530
{
2631
Repository.Dispose();
2732
try
2833
{
29-
Directory.Delete(RepositoryPath, true);
34+
//Directory.Delete(RepositoryPath, true);
3035
}
3136
catch (Exception e)
3237
{
3338
Console.WriteLine("Failed to clean up repository path at {0}. Received exception: {1}", RepositoryPath, e.Message);
3439
}
3540
}
41+
42+
public ExecutionResults ExecuteGitVersion()
43+
{
44+
return GitVersionHelper.ExecuteIn(RepositoryPath);
45+
}
3646
}
3747
}

AcceptanceTests/EmptyRepositorySpecification.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

AcceptanceTests/ExecArgSpecification.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+

2+
namespace GitHubFlowVersion.AcceptanceTests
3+
{
4+
using global::AcceptanceTests.Properties;
5+
using System.IO;
6+
using Helpers;
7+
using Shouldly;
8+
using Xunit;
9+
10+
public class ExecCmdLineArgumentTest
11+
{
12+
private const string MsBuild = @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
13+
private const string TaggedVersion = "1.2.3";
14+
15+
[Fact]
16+
public void RunExecViaCommandLine()
17+
{
18+
using (var fixture = new EmptyRepositoryFixture())
19+
{
20+
fixture.Repository.MakeATaggedCommit(TaggedVersion);
21+
fixture.Repository.MakeACommit();
22+
23+
var buildFile = Path.Combine(fixture.RepositoryPath, "TestBuildFile.proj");
24+
File.WriteAllBytes(buildFile, Resources.TestBuildFile);
25+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, MsBuild, "TestBuildFile.proj /target:OutputResults");
26+
27+
result.ExitCode.ShouldBe(0);
28+
result.Log.ShouldContain("GitVersion_FullSemVer: 1.2.4+1");
29+
}
30+
}
31+
}
32+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace AcceptanceTests.GitFlow
2+
{
3+
using GitHubFlowVersion.AcceptanceTests;
4+
using GitHubFlowVersion.AcceptanceTests.Helpers;
5+
using GitVersion;
6+
using LibGit2Sharp;
7+
using Shouldly;
8+
using Xunit;
9+
10+
public class DevelopScenarios
11+
{
12+
[Fact]
13+
public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
14+
{
15+
using (var fixture = new EmptyRepositoryFixture())
16+
{
17+
fixture.Repository.MakeATaggedCommit("1.0.0");
18+
fixture.Repository.CreateBranch("develop").Checkout();
19+
20+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
21+
22+
result.OutputVariables[VariableProvider.SemVer].ShouldBe("1.1.0.1-unstable");
23+
}
24+
}
25+
}
26+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
namespace AcceptanceTests.GitFlow
2+
{
3+
using GitHubFlowVersion.AcceptanceTests;
4+
using GitHubFlowVersion.AcceptanceTests.Helpers;
5+
using GitVersion;
6+
using LibGit2Sharp;
7+
using Shouldly;
8+
using Xunit;
9+
10+
public class UncycloScenarios
11+
{
12+
/// <summary>
13+
/// https://github.com/Particular/GitVersion/wiki/GitFlowExamples#minor-release
14+
/// </summary>
15+
/* These will be slightly out of sync because we need to make a commit to force a merge commit
16+
participant featureAbc
17+
participant develop
18+
participant release-1.3.0
19+
master -> master: tag 1.2.0
20+
master -> develop: merge
21+
note over develop: 1.3.0.0-unstable
22+
develop -> featureAbc: branch
23+
note over featureAbc: Open Pull Request #2
24+
note over featureAbc: 1.3.0-PullRequest.2+0
25+
featureAbc -> featureAbc: commit
26+
note over featureAbc: 1.3.0-PullRequest.2+1
27+
featureAbc -> develop: merge --no-ff
28+
note over develop: 1.3.0.3-unstable
29+
develop -> release-1.3.0: branch
30+
note over release-1.3.0: 1.3.0-beta.1+0
31+
develop -> develop: commit
32+
note over develop: 1.3.0.4-unstable
33+
release-1.3.0 -> release-1.3.0: commit
34+
note over release-1.3.0: 1.3.0-beta.1+1
35+
release-1.3.0 -> release-1.3.0: tag 1.3.0-beta.1
36+
note over release-1.3.0: 1.3.0-beta.2+1
37+
release-1.3.0 -> master: merge and tag master 1.3.0
38+
note over master: 1.3.0
39+
release-1.3.0 -> develop: merge --no-ff
40+
note over develop: 1.4.0.2-unstable
41+
*/
42+
[Fact]
43+
public void MinorReleaseExample()
44+
{
45+
using (var fixture = new EmptyRepositoryFixture())
46+
{
47+
fixture.Repository.MakeATaggedCommit("1.2.0");
48+
49+
// Branch to develop
50+
fixture.Repository.CreateBranch("develop").Checkout();
51+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0.0-unstable");
52+
53+
// Open Pull Request
54+
fixture.Repository.CreateBranch("pull/2/merge").Checkout();
55+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-PullRequest.2+0");
56+
fixture.Repository.MakeACommit();
57+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-PullRequest.2+1");
58+
59+
// Merge into develop
60+
fixture.Repository.Checkout("develop");
61+
fixture.Repository.MergeNoFF("pull/2/merge", Constants.SignatureNow());
62+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0.3-unstable");
63+
64+
// Create release branch
65+
fixture.Repository.CreateBranch("release-1.3.0").Checkout();
66+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-beta.1+0");
67+
68+
// Make another commit on develop
69+
fixture.Repository.Checkout("develop");
70+
fixture.Repository.MakeACommit();
71+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0.4-unstable");
72+
73+
// Make a commit to release-1.3.0
74+
fixture.Repository.Checkout("release-1.3.0");
75+
fixture.Repository.MakeACommit();
76+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-beta.1+1");
77+
78+
// Apply beta.0 tag
79+
fixture.Repository.ApplyTag("1.3.0-beta.1");
80+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0-beta.2+1");
81+
82+
// Merge release branch to master
83+
fixture.Repository.Checkout("master");
84+
// No way to force a merge commit in libgit2, so commit before merge
85+
fixture.Repository.MakeACommit();
86+
fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
87+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.3.0");
88+
fixture.Repository.ApplyTag("1.3.0");
89+
90+
// Verify develop version
91+
fixture.Repository.Checkout("develop");
92+
fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
93+
fixture.ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.4.0.3-unstable");
94+
}
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)