Skip to content

Commit 102697b

Browse files
committed
Merge pull request #165 from Particular/release-1.0.0
Release 1.0.0
2 parents 5b0ebbb + 046a1c8 commit 102697b

21 files changed

+124
-149
lines changed

AcceptanceTests/AcceptanceTests.csproj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
<Compile Include="GitHubFlow\OtherBranchTests.cs" />
7373
<Compile Include="GitHubFlow\ReleaseBranchTests.cs" />
7474
<Compile Include="Helpers\Constants.cs" />
75+
<Compile Include="Helpers\InProcessExecutionResults.cs" />
76+
<Compile Include="ModuleInitializer.cs" />
7577
<Compile Include="PullRequestInTeamCityTest.cs" />
7678
<Compile Include="EmptyRepositoryFixture.cs" />
7779
<Compile Include="Helpers\ExecutionResults.cs" />
@@ -110,7 +112,9 @@
110112
<Name>GitVersionExe</Name>
111113
</ProjectReference>
112114
</ItemGroup>
113-
<ItemGroup />
115+
<ItemGroup>
116+
<Content Include="FodyWeavers.xml" />
117+
</ItemGroup>
114118
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
115119
<PropertyGroup>
116120
<PostBuildEvent>
@@ -120,6 +124,13 @@ xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.17.0.0\lib\net35\NativeBin
120124
if not exist "$(TargetDir)NativeBinaries\amd64" md "$(TargetDir)NativeBinaries\amd64"
121125
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.17.0.0\lib\net35\NativeBinaries\amd64\*.*" "$(TargetDir)NativeBinaries\amd64"</PostBuildEvent>
122126
</PropertyGroup>
127+
<Import Project="..\packages\Fody.1.22.1\build\Fody.targets" Condition="Exists('..\packages\Fody.1.22.1\build\Fody.targets')" />
128+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
129+
<PropertyGroup>
130+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
131+
</PropertyGroup>
132+
<Error Condition="!Exists('..\packages\Fody.1.22.1\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.22.1\build\Fody.targets'))" />
133+
</Target>
123134
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
124135
Other similar extension points exist, see Microsoft.Common.targets.
125136
<Target Name="BeforeBuild">

AcceptanceTests/FodyWeavers.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Weavers>
3+
<ModuleInit />
4+
</Weavers>

AcceptanceTests/GitFlow/BaseGitFlowRepositoryFixture.cs

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,32 @@ namespace AcceptanceTests.GitFlow
77
using LibGit2Sharp;
88
using Shouldly;
99

10-
public class BaseGitFlowRepositoryFixture : IDisposable
10+
public class BaseGitFlowRepositoryFixture : EmptyRepositoryFixture
1111
{
12-
public string RepositoryPath;
13-
public Repository Repository;
14-
1512
public BaseGitFlowRepositoryFixture(string initialVersion)
1613
{
1714
SetupRepo(r => r.MakeATaggedCommit(initialVersion));
1815
}
1916

20-
public BaseGitFlowRepositoryFixture(Action<Repository> initialMasterAction)
17+
public BaseGitFlowRepositoryFixture(Action<IRepository> initialMasterAction)
2118
{
2219
SetupRepo(initialMasterAction);
2320
}
2421

25-
void SetupRepo(Action<Repository> initialMasterAction)
22+
void SetupRepo(Action<IRepository> initialMasterAction)
2623
{
27-
RepositoryPath = PathHelper.GetTempPath();
28-
Repository.Init(RepositoryPath);
29-
Console.WriteLine("Created git repository at {0}", RepositoryPath);
30-
31-
Repository = new Repository(RepositoryPath);
32-
Repository.Config.Set("user.name", "Test");
33-
Repository.Config.Set("user.email", "[email protected]");
34-
3524
var randomFile = Path.Combine(Repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
3625
File.WriteAllText(randomFile, string.Empty);
3726
Repository.Index.Stage(randomFile);
3827

3928
initialMasterAction(Repository);
4029

41-
4230
Repository.CreateBranch("develop").Checkout();
43-
4431
}
4532

4633
public void AssertFullSemver(string fullSemver)
4734
{
4835
ExecuteGitVersion().OutputVariables[VariableProvider.FullSemVer].ShouldBe(fullSemver);
4936
}
50-
51-
public void Dispose()
52-
{
53-
Repository.Dispose();
54-
try
55-
{
56-
DirectoryHelper.DeleteDirectory(RepositoryPath);
57-
}
58-
catch (Exception e)
59-
{
60-
Console.WriteLine("Failed to clean up repository path at {0}. Received exception: {1}", RepositoryPath, e.Message);
61-
}
62-
}
63-
64-
public ExecutionResults ExecuteGitVersion()
65-
{
66-
return GitVersionHelper.ExecuteIn(RepositoryPath);
67-
}
6837
}
69-
}
38+
}

AcceptanceTests/GitFlow/DevelopScenarios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
1616
fixture.Repository.MakeATaggedCommit("1.0.0");
1717
fixture.Repository.CreateBranch("develop").Checkout();
1818

19-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
19+
var result = fixture.ExecuteGitVersion();
2020

2121
result.OutputVariables[VariableProvider.SemVer].ShouldBe("1.1.0.0-unstable");
2222
}

AcceptanceTests/GitFlow/PatchScenarios.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace AcceptanceTests.GitFlow
22
{
33
using System.Linq;
4+
using System.Threading;
45
using Helpers;
56
using LibGit2Sharp;
67
using Xunit;
@@ -25,7 +26,6 @@ public void PatchLatestReleaseExample()
2526
fixture.Repository.Checkout("master");
2627

2728

28-
// No way to force a merge commit in libgit2, so commit before merge
2929
fixture.Repository.MergeNoFF("hotfix-1.2.1", Constants.SignatureNow());
3030
fixture.AssertFullSemver("1.2.1");
3131

@@ -36,7 +36,14 @@ public void PatchLatestReleaseExample()
3636
fixture.Repository.Checkout("develop");
3737
fixture.AssertFullSemver("1.3.0.0-unstable");
3838

39+
// Warning: Hack-ish hack
40+
//
41+
// Ensure the merge commit is done at a different time than the previous one
42+
// Otherwise, as they would have the same content and signature, the same sha would be generated.
43+
// Thus 'develop' and 'master' would point at the same exact commit and the Assert below would fail.
44+
Thread.Sleep(1000);
3945
fixture.Repository.MergeNoFF("hotfix-1.2.1", Constants.SignatureNow());
46+
4047
fixture.AssertFullSemver("1.3.0.1-unstable");
4148
}
4249
}
@@ -63,8 +70,6 @@ public void PatchOlderReleaseExample()
6370
fixture.Repository.CreateBranch("support-1.2", (Commit)fixture.Repository.Tags.Single(t => t.Name == "1.1.0").Target).Checkout();
6471
fixture.AssertFullSemver("1.1.0");
6572

66-
67-
// No way to force a merge commit in libgit2, so commit before merge
6873
fixture.Repository.MergeNoFF("hotfix-1.1.1", Constants.SignatureNow());
6974
fixture.AssertFullSemver("1.1.1");
7075

AcceptanceTests/GitHubFlow/MasterTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void GivenARepositoryWithCommitsButNoTags_VersionShouldBe_0_1()
1919
fixture.Repository.MakeACommit();
2020

2121
// When
22-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
22+
var result = fixture.ExecuteGitVersion();
2323

2424
result.ExitCode.ShouldBe(0);
2525
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("0.1.0+2");
@@ -37,7 +37,7 @@ public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchV
3737
fixture.Repository.MakeACommit();
3838
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
3939

40-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
40+
var result = fixture.ExecuteGitVersion();
4141

4242
result.ExitCode.ShouldBe(0);
4343
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.0.0+2");
@@ -55,7 +55,7 @@ public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVers
5555
fixture.Repository.MakeCommits(5);
5656
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
5757

58-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
58+
var result = fixture.ExecuteGitVersion();
5959

6060
result.ExitCode.ShouldBe(0);
6161
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.1.0+5");
@@ -71,7 +71,7 @@ public void GivenARepositoryWithTagAndNoNextVersionTxtFile_VersionShouldBeTagWit
7171
fixture.Repository.MakeATaggedCommit(TaggedVersion);
7272
fixture.Repository.MakeCommits(5);
7373

74-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
74+
var result = fixture.ExecuteGitVersion();
7575

7676
result.ExitCode.ShouldBe(0);
7777
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.0.4+5");
@@ -89,7 +89,7 @@ public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWi
8989
fixture.Repository.MakeCommits(5);
9090
fixture.Repository.AddNextVersionTxtFile(NextVersionTxt);
9191

92-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
92+
var result = fixture.ExecuteGitVersion();
9393

9494
result.ExitCode.ShouldBe(0);
9595
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("1.1.1+5");

AcceptanceTests/GitHubFlow/ReleaseBranchTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void CanTakeVersionFromReleaseBranch()
2020
fixture.Repository.CreateBranch("release-2.0.0");
2121
fixture.Repository.Checkout("release-2.0.0");
2222

23-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
23+
var result = fixture.ExecuteGitVersion();
2424

2525
result.ExitCode.ShouldBe(0);
2626
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("2.0.0-beta.1+5");
@@ -41,11 +41,11 @@ public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt()
4141
fixture.Repository.Checkout("master");
4242
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());
4343

44-
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
44+
var result = fixture.ExecuteGitVersion();
4545

4646
result.ExitCode.ShouldBe(0);
4747
result.OutputVariables[VariableProvider.FullSemVer].ShouldBe("2.0.0+6");
4848
}
4949
}
5050
}
51-
}
51+
}

AcceptanceTests/Helpers/ExecutionResults.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public ExecutionResults(int exitCode, string output, string logContents)
1414

1515
public int ExitCode { get; private set; }
1616
public string Output { get; private set; }
17-
public string Log { get; set; }
17+
public string Log { get; private set; }
1818

19-
public Dictionary<string, string> OutputVariables
19+
public virtual Dictionary<string, string> OutputVariables
2020
{
2121
get { return new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(Output); }
2222
}
2323
}
24-
}
24+
}

AcceptanceTests/Helpers/GitHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ public static Commit MakeACommit(this IRepository repository)
1717
}
1818
public static void MergeNoFF(this IRepository repository, string branch, Signature sig)
1919
{
20-
repository.Merge(repository.FindBranch(branch).Tip, sig, new MergeOptions
20+
repository.Merge(repository.FindBranch(branch), sig, new MergeOptions
2121
{
2222
FastForwardStrategy = FastForwardStrategy.NoFastFoward
2323
});
24-
repository.Commit(string.Format("Merge branch '{0}'", branch), amendPreviousCommit: true);
2524
}
2625

2726
public static Commit[] MakeCommits(this IRepository repository, int numCommitsToMake)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace AcceptanceTests.Helpers
2+
{
3+
using System.Collections.Generic;
4+
5+
public class InProcessExecutionResults : ExecutionResults
6+
{
7+
Dictionary<string, string> variables;
8+
9+
public InProcessExecutionResults(Dictionary<string, string> variables) : base (0, "", "")
10+
{
11+
this.variables = variables;
12+
}
13+
14+
public override Dictionary<string, string> OutputVariables
15+
{
16+
get { return variables; }
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)