Skip to content

Commit 3705f6f

Browse files
committed
Fixing tests which were affected by a git race condition. See #339 (comment) for info
1 parent 3ad8b33 commit 3705f6f

File tree

7 files changed

+44
-13
lines changed

7 files changed

+44
-13
lines changed

GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
using System;
22
using System.IO;
3+
using System.Text;
34
using GitVersion;
5+
using GitVersion.Helpers;
46
using LibGit2Sharp;
57

8+
/// <summary>
9+
/// Creates a repo with a develop branch off master which is a single commit ahead of master
10+
/// </summary>
611
public class BaseGitFlowRepositoryFixture : EmptyRepositoryFixture
712
{
13+
/// <summary>
14+
/// Creates a repo with a develop branch off master which is a single commit ahead of master
15+
///
16+
/// Master will be tagged with the initial version before branching develop
17+
/// </summary>
818
public BaseGitFlowRepositoryFixture(string initialVersion) : base(new Config())
919
{
1020
SetupRepo(r => r.MakeATaggedCommit(initialVersion));
1121
}
1222

23+
/// <summary>
24+
/// Creates a repo with a develop branch off master which is a single commit ahead of master
25+
///
26+
/// The initial setup actions will be performed before branching develop
27+
/// </summary>
1328
public BaseGitFlowRepositoryFixture(Action<IRepository> initialMasterAction) : base(new Config())
1429
{
1530
SetupRepo(initialMasterAction);
@@ -24,5 +39,21 @@ void SetupRepo(Action<IRepository> initialMasterAction)
2439
initialMasterAction(Repository);
2540

2641
Repository.CreateBranch("develop").Checkout();
42+
Repository.MakeACommit();
43+
}
44+
45+
public void DumpGraph()
46+
{
47+
var output = new StringBuilder();
48+
49+
ProcessHelper.Run(
50+
o => output.AppendLine(o),
51+
e => output.AppendLineFormat("ERROR: {0}", e),
52+
null,
53+
"git",
54+
@"log --graph --abbrev-commit --decorate --date=relative --all",
55+
RepositoryPath);
56+
57+
Console.Write(output.ToString());
2758
}
2859
}

GitVersionCore.Tests/IntegrationTests/GitFlow/PatchScenarios.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public void PatchLatestReleaseExample()
1414
// create hotfix
1515
fixture.Repository.CreateBranch("hotfix-1.2.1").Checkout();
1616

17-
fixture.AssertFullSemver("1.2.1-beta.1+0");
18-
fixture.Repository.MakeACommit();
1917
fixture.AssertFullSemver("1.2.1-beta.1+1");
18+
fixture.Repository.MakeACommit();
19+
fixture.AssertFullSemver("1.2.1-beta.1+2");
2020
fixture.Repository.ApplyTag("1.2.1-beta.1");
21-
fixture.AssertFullSemver("1.2.1-beta.1+1");
21+
fixture.AssertFullSemver("1.2.1-beta.1+2");
2222
fixture.Repository.MakeACommit();
23-
fixture.AssertFullSemver("1.2.1-beta.2+2");
23+
fixture.AssertFullSemver("1.2.1-beta.2+3");
2424

2525
// Merge hotfix branch to master
2626
fixture.Repository.Checkout("master");
@@ -77,7 +77,7 @@ public void PatchOlderReleaseExample()
7777

7878
// Verify develop version
7979
fixture.Repository.Checkout("develop");
80-
fixture.AssertFullSemver("1.3.0-unstable.0+0");
80+
fixture.AssertFullSemver("1.3.0-unstable.1+1");
8181
}
8282
}
8383
}

GitVersionCore.Tests/IntegrationTests/GitFlow/SupportBranchScenarios.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public class SupportBranchScenarios
1010
public void SupportIsCalculatedCorrectly()
1111
{
1212
using (var fixture = new BaseGitFlowRepositoryFixture("1.1.0"))
13-
{
13+
{
1414
// Create 2.0.0 release
1515
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
1616
fixture.Repository.MakeCommits(2);
17-
17+
1818
// Merge into develop and master
1919
fixture.Repository.Checkout("master");
2020
fixture.Repository.MergeNoFF("release-2.0.0");
2121
fixture.Repository.ApplyTag("2.0.0");
2222
fixture.Repository.Checkout("develop");
2323
fixture.Repository.MergeNoFF("release-2.0.0");
24-
fixture.AssertFullSemver("2.1.0-unstable.0+0");
24+
fixture.AssertFullSemver("2.1.0-unstable.1+1");
2525

2626
// Now lets support 1.x release
2727
fixture.Repository.Checkout("1.1.0");
@@ -47,6 +47,6 @@ public void SupportIsCalculatedCorrectly()
4747
fixture.Repository.MergeNoFF("hotfix/1.2.1");
4848
fixture.AssertFullSemver("1.2.1");
4949
}
50-
}
50+
}
5151
}
5252
}

GitVersionCore/GitVersionCore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<Compile Include="GitFlow\BranchFinders\RecentTagVersionExtractor.cs" />
7979
<Compile Include="Helpers\FileSystem.cs" />
8080
<Compile Include="Helpers\IFileSystem.cs" />
81+
<Compile Include="Helpers\ProcessHelper.cs" />
8182
<Compile Include="LastMinorVersionFinder.cs" />
8283
<Compile Include="SemanticVersionExtensions.cs" />
8384
<Compile Include="VersioningModes\ContinuousDeliveryMode.cs" />

GitVersionExe/ProcessHelper.cs renamed to GitVersionCore/Helpers/ProcessHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GitVersion
1+
namespace GitVersion.Helpers
22
{
33
using System;
44
using System.Collections.Generic;
@@ -7,7 +7,7 @@ namespace GitVersion
77
using System.Runtime.InteropServices;
88
using System.Threading;
99

10-
static class ProcessHelper
10+
public static class ProcessHelper
1111
{
1212
static volatile object lockObject = new object();
1313

GitVersionExe.Tests/GitVersionHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Text;
5-
using GitVersion;
5+
using GitVersion.Helpers;
66
using LibGit2Sharp;
77

88
public static class GitVersionHelper

GitVersionExe/GitVersionExe.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
<Compile Include="ExtensionMethods.cs" />
5858
<Compile Include="GitPreparer.cs" />
5959
<Compile Include="HelpWriter.cs" />
60-
<Compile Include="ProcessHelper.cs" />
6160
<Compile Include="Program.cs" />
6261
<Compile Include="AssemblyInfo.cs" />
6362
<Compile Include="AssemblyInfoFileUpdate.cs" />

0 commit comments

Comments
 (0)