Skip to content

Commit 2052f25

Browse files
2 parents 292270b + 92d8616 commit 2052f25

File tree

58 files changed

+1522
-11
lines changed

Some content is hidden

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

58 files changed

+1522
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ Thumbs.db
8080
# Folder config file
8181
Desktop.ini
8282

83+
_NCrunch_GitVersion
+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{BF905F84-382C-440D-92F5-C61108626D8D}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AcceptanceTests</RootNamespace>
11+
<AssemblyName>AcceptanceTests</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="ApprovalTests">
35+
<HintPath>..\packages\ApprovalTests.3.0.5\lib\net40\ApprovalTests.dll</HintPath>
36+
</Reference>
37+
<Reference Include="ApprovalUtilities">
38+
<HintPath>..\packages\ApprovalUtilities.3.0.5\lib\net35\ApprovalUtilities.dll</HintPath>
39+
</Reference>
40+
<Reference Include="LibGit2Sharp">
41+
<HintPath>..\packages\LibGit2Sharp.0.16.0.0\lib\net35\LibGit2Sharp.dll</HintPath>
42+
</Reference>
43+
<Reference Include="System" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Web.Extensions" />
46+
<Reference Include="System.Xml.Linq" />
47+
<Reference Include="System.Data.DataSetExtensions" />
48+
<Reference Include="System.Data" />
49+
<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>
54+
<Reference Include="xunit">
55+
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
56+
</Reference>
57+
<Reference Include="xunit.extensions">
58+
<HintPath>..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
59+
</Reference>
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="EmptyRepositorySpecification.cs" />
63+
<Compile Include="ExecArgSpecification.cs" />
64+
<Compile Include="Helpers\ExecutionResults.cs" />
65+
<Compile Include="Helpers\GitHelper.cs" />
66+
<Compile Include="Helpers\GitVersionHelper.cs" />
67+
<Compile Include="Helpers\PathHelper.cs" />
68+
<Compile Include="Helpers\ProcessHelper.cs" />
69+
<Compile Include="Helpers\Scrubbers.cs" />
70+
<Compile Include="NoTagsInRepositorySpecification.cs" />
71+
<Compile Include="NoTagsInRepositoryWithNextVersionTxtSpecification.cs" />
72+
<Compile Include="ProjArgSpecification.cs" />
73+
<Compile Include="Properties\ApprovalTestsConfig.cs" />
74+
<Compile Include="Properties\AssemblyInfo.cs" />
75+
<Compile Include="Properties\Resources.Designer.cs">
76+
<AutoGen>True</AutoGen>
77+
<DesignTime>True</DesignTime>
78+
<DependentUpon>Resources.resx</DependentUpon>
79+
</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" />
85+
</ItemGroup>
86+
<ItemGroup>
87+
<None Include="packages.config" />
88+
<None Include="TestBuildFile.proj" />
89+
</ItemGroup>
90+
<ItemGroup>
91+
<EmbeddedResource Include="Properties\Resources.resx">
92+
<Generator>ResXFileCodeGenerator</Generator>
93+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
94+
</EmbeddedResource>
95+
</ItemGroup>
96+
<ItemGroup>
97+
<ProjectReference Include="..\GitVersion\GitVersion.csproj">
98+
<Project>{c3578a7b-09a6-4444-9383-0deafa4958bd}</Project>
99+
<Name>GitVersion</Name>
100+
</ProjectReference>
101+
</ItemGroup>
102+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
103+
<PropertyGroup>
104+
<PostBuildEvent>
105+
if not exist "$(TargetDir)NativeBinaries" md "$(TargetDir)NativeBinaries"
106+
if not exist "$(TargetDir)NativeBinaries\x86" md "$(TargetDir)NativeBinaries\x86"
107+
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.16.0.0\lib\net35\NativeBinaries\x86\*.*" "$(TargetDir)NativeBinaries\x86"
108+
if not exist "$(TargetDir)NativeBinaries\amd64" md "$(TargetDir)NativeBinaries\amd64"
109+
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.16.0.0\lib\net35\NativeBinaries\amd64\*.*" "$(TargetDir)NativeBinaries\amd64"</PostBuildEvent>
110+
</PropertyGroup>
111+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
112+
Other similar extension points exist, see Microsoft.Common.targets.
113+
<Target Name="BeforeBuild">
114+
</Target>
115+
<Target Name="AfterBuild">
116+
</Target>
117+
-->
118+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<ProjectConfiguration>
2+
<CopyReferencedAssembliesToWorkspace>true</CopyReferencedAssembliesToWorkspace>
3+
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
4+
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
5+
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
6+
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
7+
<AllowCodeAnalysis>false</AllowCodeAnalysis>
8+
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
9+
<RunPreBuildEvents>true</RunPreBuildEvents>
10+
<RunPostBuildEvents>true</RunPostBuildEvents>
11+
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
12+
<InstrumentAssembly>true</InstrumentAssembly>
13+
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
14+
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
15+
<DetectStackOverflow>true</DetectStackOverflow>
16+
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
17+
<DefaultTestTimeout>60000</DefaultTestTimeout>
18+
<UseBuildConfiguration></UseBuildConfiguration>
19+
<UseBuildPlatform></UseBuildPlatform>
20+
<ProxyProcessPath></ProxyProcessPath>
21+
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
22+
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
23+
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
24+
<IgnoredTests>
25+
<AllTestsSelector />
26+
</IgnoredTests>
27+
<AdditionalFilesToInclude>..\Packages\LibGit2Sharp.0.16.0.0\lib\net35\NativeBinaries\**.*</AdditionalFilesToInclude>
28+
</ProjectConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using GitHubFlowVersion.AcceptanceTests.Helpers;
2+
using Xunit;
3+
4+
namespace GitHubFlowVersion.AcceptanceTests
5+
{
6+
using System;
7+
using TestStack.BDDfy;
8+
9+
public class EmptyRepositorySpecification : IUseFixture<RepositoryFixture>
10+
{
11+
private ExecutionResults _result;
12+
RepositoryFixture _data;
13+
14+
public void GivenAnEmptyRepository() {}
15+
16+
public void WhenGitHubFlowVersionIsExecuted()
17+
{
18+
_result = GitVersionHelper.ExecuteIn(_data.RepositoryPath);
19+
}
20+
21+
public void ThenANonZeroExitCodeShouldOccur()
22+
{
23+
Assert.NotEqual(0, _result.ExitCode);
24+
}
25+
26+
public void AndAnErrorAboutNotFindingMasterShouldBeShown()
27+
{
28+
Assert.Contains("No Tip found. Has repo been initialized?", _result.Output);
29+
}
30+
31+
[Fact]
32+
public void RunSpecification()
33+
{
34+
// If we are actually running in teamcity, lets delete this environmental variable
35+
Environment.SetEnvironmentVariable("TEAMCITY_VERSION", null);
36+
this.BDDfy();
37+
}
38+
39+
public void SetFixture(RepositoryFixture data)
40+
{
41+
_data = data;
42+
}
43+
}
44+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//using System.IO;
2+
//using GitHubFlowVersion.AcceptanceTests.Helpers;
3+
//using Xunit;
4+
5+
//namespace GitHubFlowVersion.AcceptanceTests
6+
//{
7+
// using global::AcceptanceTests.Properties;
8+
9+
// public class ExecArgSpecification : RepositorySpecification
10+
// {
11+
// private ExecutionResults _result;
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+
// public void GivenARepositoryWithATaggedCommit()
16+
// {
17+
// Repository.MakeATaggedCommit(TaggedVersion);
18+
// Repository.MakeACommit();
19+
// }
20+
21+
// public void AndGivenThereIsANextVersionTxtFile()
22+
// {
23+
// Repository.AddNextVersionTxtFile(TaggedVersion);
24+
// }
25+
26+
// public void WhenGitHubFlowVersionIsExecutedWithExecOption()
27+
// {
28+
// var buildFile = Path.Combine(RepositoryPath, "TestBuildFile.proj");
29+
// File.WriteAllBytes(buildFile, Resources.TestBuildFile);
30+
// _result = GitVersionHelper.ExecuteIn(RepositoryPath, exec: MsBuild, execArgs: "TestBuildFile.proj /target:OutputResults");
31+
// }
32+
33+
// public void ThenProcessExitedWithoutError()
34+
// {
35+
// _result.AssertExitedSuccessfully();
36+
// }
37+
38+
// public void AndThenVariablesShouldBeAvailableToProcess()
39+
// {
40+
// Assert.Contains("GitHubFlowVersion_FullSemVer: 1.2.4+001", _result.Output);
41+
// }
42+
// }
43+
//}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Xunit;
2+
3+
namespace GitHubFlowVersion.AcceptanceTests.Helpers
4+
{
5+
public class ExecutionResults
6+
{
7+
public ExecutionResults(int exitCode, string output)
8+
{
9+
ExitCode = exitCode;
10+
Output = output;
11+
}
12+
13+
public int ExitCode { get; private set; }
14+
public string Output { get; private set; }
15+
16+
public void AssertExitedSuccessfully()
17+
{
18+
Assert.Equal(0, ExitCode);
19+
}
20+
}
21+
}

AcceptanceTests/Helpers/GitHelper.cs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using LibGit2Sharp;
5+
6+
namespace GitHubFlowVersion.AcceptanceTests.Helpers
7+
{
8+
public static class GitHelper
9+
{
10+
public static Commit MakeACommit(this IRepository repository)
11+
{
12+
var randomFile = Path.Combine(repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
13+
File.WriteAllText(randomFile, string.Empty);
14+
repository.Index.Stage(randomFile);
15+
return repository.Commit("Test Commit", new Signature("Test User", "[email protected]", DateTimeOffset.UtcNow));
16+
}
17+
18+
public static Commit[] MakeCommits(this IRepository repository, int numCommitsToMake)
19+
{
20+
return Enumerable.Range(1, numCommitsToMake)
21+
.Select(x => repository.MakeACommit())
22+
.ToArray();
23+
}
24+
25+
public static Tag MakeATaggedCommit(this IRepository repository, string tag)
26+
{
27+
var commit = repository.MakeACommit();
28+
var existingTag = repository.Tags.SingleOrDefault(t=>t.Name == tag);
29+
if (existingTag != null)
30+
return existingTag;
31+
return repository.Tags.Add(tag, commit);
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.IO;
3+
using System.Text;
4+
using LibGit2Sharp;
5+
6+
namespace GitHubFlowVersion.AcceptanceTests.Helpers
7+
{
8+
public static class GitVersionHelper
9+
{
10+
public static ExecutionResults ExecuteIn(string workingDirectory, string toFile = null,
11+
string exec = null, string execArgs = null, string projectFile = null, string targets = null)
12+
{
13+
var gitHubFlowVersion = Path.Combine(PathHelper.GetCurrentDirectory(), "GitVersion.exe");
14+
var toFileArg = toFile == null ? null : string.Format(" /ToFile \"{0}\"", toFile);
15+
var execArg = exec == null ? null : string.Format(" /Exec \"{0}\"", exec);
16+
var execArgsArg = execArgs == null ? null : string.Format(" /ExecArgs \"{0}\"", execArgs);
17+
var projectFileArg = projectFile == null ? null : string.Format(" /ProjectFile \"{0}\"", projectFile);
18+
var targetsArg = targets == null ? null : string.Format(" /Targets \"{0}\"", targets);
19+
var arguments = string.Format("\"{0}\"{1}{2}{3}{4}{5}", workingDirectory, toFileArg, execArg, execArgsArg,
20+
projectFileArg, targetsArg);
21+
22+
var output = new StringBuilder();
23+
24+
Console.WriteLine("Executing: {0} {1}", gitHubFlowVersion, arguments);
25+
Console.WriteLine();
26+
var exitCode = ProcessHelper.Run(s => output.AppendLine(s), s => output.AppendLine(s), null, gitHubFlowVersion, arguments, workingDirectory);
27+
28+
Console.WriteLine("Output from GitHubFlowVersion.exe");
29+
Console.WriteLine("-------------------------------------------------------");
30+
Console.WriteLine(output.ToString());
31+
Console.WriteLine();
32+
Console.WriteLine();
33+
Console.WriteLine("-------------------------------------------------------");
34+
35+
return new ExecutionResults(exitCode, output.ToString());
36+
}
37+
38+
public static void AddNextVersionTxtFile(this IRepository repository, string version)
39+
{
40+
var nextVersionFile = Path.Combine(repository.Info.WorkingDirectory, "NextVersion.txt");
41+
File.WriteAllText(nextVersionFile, version);
42+
}
43+
}
44+
}

AcceptanceTests/Helpers/PathHelper.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
5+
namespace GitHubFlowVersion.AcceptanceTests.Helpers
6+
{
7+
public static class PathHelper
8+
{
9+
public static string GetCurrentDirectory()
10+
{
11+
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
12+
}
13+
14+
public static string GetTempPath()
15+
{
16+
return Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)