Skip to content
Closed
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
5 changes: 3 additions & 2 deletions GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ void SetupRepo(Action<IRepository> initialMasterAction)
{
var randomFile = Path.Combine(Repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
File.WriteAllText(randomFile, string.Empty);
Repository.Index.Stage(randomFile);
Repository.Stage(randomFile);

initialMasterAction(Repository);

Repository.CreateBranch("develop").Checkout();
var branch = Repository.CreateBranch("develop");
Repository.Checkout(branch);
}
}
10 changes: 5 additions & 5 deletions GitVersionCore.Tests/GitVersionCore.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props" Condition="Exists('..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props')" />
<Import Project="..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props" Condition="Exists('..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -13,7 +13,7 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>e51a7a82</NuGetPackageImportStamp>
<NuGetPackageImportStamp>4bc839db</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -43,9 +43,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ApprovalUtilities.3.0.7\lib\net35\ApprovalUtilities.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp, Version=0.20.1.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.20.1.0\lib\net40\LibGit2Sharp.dll</HintPath>
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150223185624\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -130,6 +130,6 @@
<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>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.1.26.4\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.26.4\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props'))" />
<Error Condition="!Exists('..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props'))" />
</Target>
</Project>
25 changes: 21 additions & 4 deletions GitVersionCore.Tests/Helpers/GitTestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public static Commit MakeACommit(this IRepository repository)

public static Commit MakeACommit(this IRepository repository, DateTimeOffset dateTimeOffset)
{
var randomFile = Path.Combine(repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
File.WriteAllText(randomFile, string.Empty);
repository.Index.Stage(randomFile);
return repository.Commit("Test Commit", Constants.Signature(dateTimeOffset), Constants.Signature(dateTimeOffset));
return CreateFileAndCommit(repository, Guid.NewGuid().ToString(), dateTimeOffset);
}

public static void MergeNoFF(this IRepository repository, string branch)
Expand All @@ -39,6 +36,26 @@ public static Commit[] MakeCommits(this IRepository repository, int numCommitsTo
.ToArray();
}

public static Commit CreateFileAndCommit(this IRepository repository, string relativeFileName, DateTimeOffset dateTimeOffset = default(DateTimeOffset))
{
if (dateTimeOffset == default(DateTimeOffset))
{
dateTimeOffset = DateTimeOffset.Now;
}

var randomFile = Path.Combine(repository.Info.WorkingDirectory, relativeFileName);
if (File.Exists(randomFile))
{
File.Delete(randomFile);
}

File.WriteAllText(randomFile, Guid.NewGuid().ToString());

repository.Stage(randomFile);
return repository.Commit(string.Format("Test Commit for file '{0}'", relativeFileName),
Constants.Signature(dateTimeOffset), Constants.Signature(dateTimeOffset));
}

public static Tag MakeATaggedCommit(this IRepository repository, string tag)
{
var commit = repository.MakeACommit();
Expand Down
18 changes: 12 additions & 6 deletions GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
var branch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(branch);
fixture.AssertFullSemver("1.1.0-unstable.0+0");
}
}
Expand All @@ -22,8 +23,10 @@ public void MergingReleaseBranchBackIntoDevelopWithoutMergingToMaster_DoesNotBum
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
var developBranch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(developBranch);
var releaseBranch = fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout(releaseBranch);
fixture.AssertFullSemver("2.0.0-beta.1+0");
fixture.Repository.Checkout("develop");
fixture.AssertFullSemver("1.1.0-unstable.0+0");
Expand All @@ -41,7 +44,8 @@ public void CanChangeDevelopTagViaConfig()
}))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
var branch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(branch);
fixture.AssertFullSemver("1.1.0-alpha.0+0");
}
}
Expand All @@ -55,7 +59,8 @@ public void CanClearDevelopTagViaConfig()
}))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
var branch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(branch);
fixture.AssertFullSemver("1.1.0+0");
}
}
Expand All @@ -66,7 +71,8 @@ public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased()
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
var branch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(branch);
fixture.Repository.MakeACommit();
var commit = fixture.Repository.Head.Tip;
fixture.Repository.MakeACommit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public void SupportIsCalculatedCorrectly()
using (var fixture = new BaseGitFlowRepositoryFixture("1.1.0"))
{
// Create 2.0.0 release
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
var releaseBranch = fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout(releaseBranch);
fixture.Repository.MakeCommits(2);

// Merge into develop and master
Expand All @@ -23,11 +24,13 @@ public void SupportIsCalculatedCorrectly()

// Now lets support 1.x release
fixture.Repository.Checkout("1.1.0");
fixture.Repository.CreateBranch("support/1.0.0").Checkout();
var supportBranch = fixture.Repository.CreateBranch("support/1.0.0");
fixture.Repository.Checkout(supportBranch);
fixture.AssertFullSemver("1.1.0");

// Create release branch from support branch
fixture.Repository.CreateBranch("release/1.2.0").Checkout();
var newReleaseBranch = fixture.Repository.CreateBranch("release/1.2.0");
fixture.Repository.Checkout(newReleaseBranch);
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.0-beta.1+1");

Expand All @@ -38,7 +41,8 @@ public void SupportIsCalculatedCorrectly()
fixture.Repository.ApplyTag("1.2.0");

// Create 1.2.1 hotfix
fixture.Repository.CreateBranch("hotfix/1.2.1").Checkout();
var hotfixBranch = fixture.Repository.CreateBranch("hotfix/1.2.1");
fixture.Repository.Checkout(hotfixBranch);
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.1-beta.1+3"); // TODO This should be +1
fixture.Repository.Checkout("support/1.0.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public void PatchLatestReleaseExample()
using (var fixture = new BaseGitFlowRepositoryFixture("1.2.0"))
{
// create hotfix
fixture.Repository.CreateBranch("hotfix-1.2.1").Checkout();
var branch = fixture.Repository.CreateBranch("hotfix-1.2.1");
fixture.Repository.Checkout(branch);

fixture.AssertFullSemver("1.2.1-beta.1+0");
fixture.Repository.MakeACommit();
Expand Down Expand Up @@ -60,14 +61,16 @@ public void PatchOlderReleaseExample()
{

// create hotfix branch
fixture.Repository.CreateBranch("hotfix-1.1.1", (Commit) fixture.Repository.Tags.Single(t => t.Name == "1.1.0").Target).Checkout();
var branch = fixture.Repository.CreateBranch("hotfix-1.1.1", (Commit) fixture.Repository.Tags.Single(t => t.Name == "1.1.0").Target);
fixture.Repository.Checkout(branch);

fixture.AssertFullSemver("1.1.1-beta.1+0");
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.1.1-beta.1+1");

// Merge hotfix branch to support
fixture.Repository.CreateBranch("support-1.2", (Commit) fixture.Repository.Tags.Single(t => t.Name == "1.1.0").Target).Checkout();
var supportBranch = fixture.Repository.CreateBranch("support-1.2", (Commit) fixture.Repository.Tags.Single(t => t.Name == "1.1.0").Target);
fixture.Repository.Checkout(supportBranch);
fixture.AssertFullSemver("1.1.0");

fixture.Repository.MergeNoFF("hotfix-1.1.1", Constants.SignatureNow());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReac
fixture.Repository.MakeCommits(5);
fixture.Repository.MakeATaggedCommit("1.0.0.0");
fixture.Repository.MakeCommits(2);
fixture.Repository.CreateBranch("develop").Checkout();
var branch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(branch);
fixture.AssertFullSemver("1.1.0-unstable.0+0");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ public void MinorReleaseExample()
fixture.Repository.MakeATaggedCommit("1.2.0");

// Branch to develop
fixture.Repository.CreateBranch("develop").Checkout();
var developBranch = fixture.Repository.CreateBranch("develop");
fixture.Repository.Checkout(developBranch);
fixture.AssertFullSemver("1.3.0-unstable.0+0");

// Open Pull Request
fixture.Repository.CreateBranch("pull/2/merge").Checkout();
var pullBranch = fixture.Repository.CreateBranch("pull/2/merge");
fixture.Repository.Checkout(pullBranch);
fixture.AssertFullSemver("1.3.0-PullRequest.2+0");
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.3.0-PullRequest.2+1");
Expand All @@ -58,7 +60,8 @@ public void MinorReleaseExample()
fixture.AssertFullSemver("1.3.0-unstable.2+2");

// Create release branch
fixture.Repository.CreateBranch("release-1.3.0").Checkout();
var releaseBranch = fixture.Repository.CreateBranch("release-1.3.0");
fixture.Repository.Checkout(releaseBranch);
fixture.AssertFullSemver("1.3.0-beta.1+0");

// Make another commit on develop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public void SupportIsCalculatedCorrectly()
fixture.Repository.ApplyTag("1.1.0");

// Create 2.0.0 release
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
var releaseBranch = fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout(releaseBranch);
fixture.Repository.MakeCommits(2);

// Merge into develop and master
Expand All @@ -26,11 +27,13 @@ public void SupportIsCalculatedCorrectly()

// Now lets support 1.x release
fixture.Repository.Checkout("1.1.0");
fixture.Repository.CreateBranch("support/1.0.0").Checkout();
var supportBranch = fixture.Repository.CreateBranch("support/1.0.0");
fixture.Repository.Checkout(supportBranch);
fixture.AssertFullSemver("1.1.0+0");

// Create release branch from support branch
fixture.Repository.CreateBranch("release/1.2.0").Checkout();
var newReleaseBranch = fixture.Repository.CreateBranch("release/1.2.0");
fixture.Repository.Checkout(newReleaseBranch);
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.0-beta.1+1");

Expand All @@ -41,7 +44,8 @@ public void SupportIsCalculatedCorrectly()
fixture.Repository.ApplyTag("1.2.0");

// Create 1.2.1 hotfix
fixture.Repository.CreateBranch("hotfix/1.2.1").Checkout();
var hotfixBranch = fixture.Repository.CreateBranch("hotfix/1.2.1");
fixture.Repository.Checkout(hotfixBranch);
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.1+1");
fixture.Repository.Checkout("support/1.0.0");
Expand Down
2 changes: 1 addition & 1 deletion GitVersionCore.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="ApprovalTests" version="3.0.7" targetFramework="net45" />
<package id="ApprovalUtilities" version="3.0.7" targetFramework="net45" />
<package id="Fody" version="1.26.4" targetFramework="net45" developmentDependency="true" />
<package id="LibGit2Sharp" version="0.20.1.0" targetFramework="net45" />
<package id="LibGit2Sharp" version="0.22.0-pre20150223185624" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="Shouldly" version="2.3.1" targetFramework="net45" />
<package id="YamlDotNet" version="3.5.0" targetFramework="net45" />
Expand Down
3 changes: 2 additions & 1 deletion GitVersionCore/BuildServers/GitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static void NormalizeGitDirectory(string gitDirectory, Authentication aut
else
{
Logger.WriteInfo(string.Format("Checking out local branch 'refs/heads/{0}'.", localBranchesWhereCommitShaIsHead[0].Name));
repo.Branches[localBranchesWhereCommitShaIsHead[0].Name].Checkout();
var branch = repo.Branches[localBranchesWhereCommitShaIsHead[0].Name];
repo.Checkout(branch);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions GitVersionCore/GitVersionCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props" Condition="Exists('..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props')" />
<Import Project="..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props" Condition="Exists('..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -12,7 +12,7 @@
<AssemblyName>GitVersionCore</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>c31ea180</NuGetPackageImportStamp>
<NuGetPackageImportStamp>0a9a46a9</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -39,9 +39,9 @@
<HintPath>..\packages\JetBrainsAnnotations.Fody.1.0.2\Lib\JetBrains.Annotations.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="LibGit2Sharp, Version=0.20.1.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.20.1.0\lib\net40\LibGit2Sharp.dll</HintPath>
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150223185624\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -141,7 +141,7 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\PepitaPackage.1.21.4\build\PepitaPackage.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PepitaPackage.1.21.4\build\PepitaPackage.targets'))" />
<Error Condition="!Exists('..\packages\Fody.1.26.4\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.26.4\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.0.20.1.0\build\net40\LibGit2Sharp.props'))" />
<Error Condition="!Exists('..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.0.22.0-pre20150223185624\build\net40\LibGit2Sharp.props'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>
Expand Down
2 changes: 1 addition & 1 deletion GitVersionCore/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Caseless.Fody" version="1.3.3.0" targetFramework="net40" developmentDependency="true" />
<package id="Fody" version="1.26.4" targetFramework="net40" developmentDependency="true" />
<package id="JetBrainsAnnotations.Fody" version="1.0.2" targetFramework="net40" developmentDependency="true" />
<package id="LibGit2Sharp" version="0.20.1.0" targetFramework="net40" />
<package id="LibGit2Sharp" version="0.22.0-pre20150223185624" targetFramework="net40" />
<package id="PepitaPackage" version="1.21.4" targetFramework="net40" developmentDependency="true" />
<package id="Visualize.Fody" version="0.4.0.0" targetFramework="net40" developmentDependency="true" />
<package id="YamlDotNet" version="3.5.0" targetFramework="net40" />
Expand Down
Loading