Skip to content

Config file updates #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 17, 2014
Merged
Show file tree
Hide file tree
Changes from 16 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
34 changes: 34 additions & 0 deletions GitVersionCore.Tests/ConfigReaderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.IO;
using GitVersion;
using GitVersion.Configuration;
using NUnit.Framework;
using Shouldly;

[TestFixture]
public class ConfigReaderTests
{

[Test]
public void CanReadDocument()
{
const string text = @"
assemblyVersioningScheme: MajorMinor
develop-branch-tag: alpha
release-branch-tag: rc
";
var config = ConfigReader.Read(new StringReader(text));
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinor);
config.DevelopBranchTag.ShouldBe("alpha");
config.ReleaseBranchTag.ShouldBe("rc");
}

[Test]
public void CanReadDefaultDocument()
{
const string text = "";
var config = ConfigReader.Read(new StringReader(text));
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
config.DevelopBranchTag.ShouldBe("unstable");
config.ReleaseBranchTag.ShouldBe("beta");
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using System.IO;
using GitVersion.Configuration;
using LibGit2Sharp;

public class BaseGitFlowRepositoryFixture : EmptyRepositoryFixture
{
public BaseGitFlowRepositoryFixture(string initialVersion)
public BaseGitFlowRepositoryFixture(string initialVersion) : base(new Config())
{
SetupRepo(r => r.MakeATaggedCommit(initialVersion));
}

public BaseGitFlowRepositoryFixture(Action<IRepository> initialMasterAction)
public BaseGitFlowRepositoryFixture(Action<IRepository> initialMasterAction) : base(new Config())
{
SetupRepo(initialMasterAction);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.IO;
using GitVersion.Configuration;
using LibGit2Sharp;

public class CommitCountingRepoFixture : RepositoryFixtureBase
{
public CommitCountingRepoFixture() :
base(CloneTestRepo)
base(CloneTestRepo, new Config())
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using GitVersion.Configuration;
using LibGit2Sharp;

public class EmptyRepositoryFixture : RepositoryFixtureBase
{
public EmptyRepositoryFixture() :
base(CreateNewRepository)
public EmptyRepositoryFixture(Config configuration) :
base(CreateNewRepository, configuration)
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using GitVersion;
using GitVersion.Configuration;
using LibGit2Sharp;
using Shouldly;

public abstract class RepositoryFixtureBase : IDisposable
{
public string RepositoryPath;
public IRepository Repository;
private Config configuration;

protected RepositoryFixtureBase(Func<string, IRepository> repoBuilder)
protected RepositoryFixtureBase(Func<string, IRepository> repoBuilder, Config configuration)
{
this.configuration = configuration;
RepositoryPath = PathHelper.GetTempPath();
Repository = repoBuilder(RepositoryPath);
Repository.Config.Set("user.name", "Test");
Expand All @@ -19,7 +22,7 @@ protected RepositoryFixtureBase(Func<string, IRepository> repoBuilder)
public SemanticVersion ExecuteGitVersion()
{
var vf = new GitVersionFinder();
return vf.FindVersion(new GitVersionContext(Repository));
return vf.FindVersion(new GitVersionContext(Repository, configuration));
}

public void AssertFullSemver(string fullSemver)
Expand Down
32 changes: 0 additions & 32 deletions GitVersionCore.Tests/GitFlow/DevelopScenarios.cs

This file was deleted.

93 changes: 82 additions & 11 deletions GitVersionCore.Tests/GitVersionCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,99 @@
<Compile Include="..\GitVersionTask.Tests\Helpers\DirectoryHelper.cs">
<Link>Helpers\DirectoryHelper.cs</Link>
</Compile>
<Compile Include="CommitCountingRepoFixture.cs" />
<Compile Include="Fixtures\CommitCountingRepoFixture.cs" />
<Compile Include="ConfigReaderTests.cs" />
<Compile Include="GitDirFinderTests.cs" />
<Compile Include="GitFlow\BaseGitFlowRepositoryFixture.cs" />
<Compile Include="GitFlow\DevelopScenarios.cs" />
<Compile Include="GitFlow\MetaDataByCommitFixture.cs" />
<Compile Include="GitFlow\PatchScenarios.cs" />
<Compile Include="GitFlow\WikiScenarios.cs" />
<Compile Include="GitHubFlow\OtherBranchTests.cs" />
<Compile Include="GitHubFlow\ReleaseBranchTests.cs" />
<Compile Include="Fixtures\BaseGitFlowRepositoryFixture.cs" />
<Compile Include="IntegrationTests\GitFlow\DevelopScenarios.cs" />
<Compile Include="IntegrationTests\GitFlow\MetaDataByCommitScenarios.cs" />
<Compile Include="IntegrationTests\GitFlow\PatchScenarios.cs" />
<Compile Include="IntegrationTests\GitFlow\ReleaseBranchTests.cs" />
<Compile Include="IntegrationTests\GitFlow\WikiScenarios.cs" />
<Compile Include="IntegrationTests\GitHubFlow\OtherBranchTests.cs" />
<Compile Include="IntegrationTests\GitHubFlow\ReleaseBranchTests.cs" />
<Compile Include="Helpers\Constants.cs" />
<Compile Include="Helpers\NextVersionWriter.cs" />
<Compile Include="InformationalVersionBuilderTests.cs" />
<Compile Include="JsonVersionBuilderTests.cs" />
<Compile Include="LastVersionOnMasterFinderTests.cs" />
<Compile Include="ModuleInitializer.cs" />
<Compile Include="EmptyRepositoryFixture.cs" />
<Compile Include="Fixtures\EmptyRepositoryFixture.cs" />
<Compile Include="Helpers\GitHelper.cs" />
<Compile Include="Helpers\PathHelper.cs" />
<Compile Include="GitHubFlow\MasterTests.cs" />
<Compile Include="IntegrationTests\GitHubFlow\MasterTests.cs" />
<Compile Include="ApprovalTestsConfig.cs" />
<Compile Include="RepositoryFixtureBase.cs" />
<Compile Include="Fixtures\RepositoryFixtureBase.cs" />
<Compile Include="SemanticVersionTests.cs" />
<Compile Include="ShortVersionParserTests.cs" />
<Compile Include="VariableProviderTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\commit_counting_wd\gitted\config" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are all these files that got added into the project?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows nCrunch and other things to track the dependency. Can do it via config as well if we prefer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. No. that's fine, I was just curious as to what they are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so @gep13 is smarter than me

Allows nCrunch and other things to track the dependency

what do u mean by this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no smarts involved here. I have never used nCrunch, so I took it that Jake knew what he was talking about and I left it at that :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nCrunch creates a temporary working directory. I can exclude this and then tell nCrunch to include these files via config instead. Don't mind which. but they are required for the tests to run

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be done with a **/*.* hidden node hack instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this should not block the PR. i can hack it later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can switch to nCrunch config if you want? There are a few other things I need to cleanup, so will exclude and change to config.

<None Include="Resources\commit_counting_wd\gitted\HEAD" />
<None Include="Resources\commit_counting_wd\gitted\index" />
<None Include="Resources\commit_counting_wd\gitted\info\exclude" />
<None Include="Resources\commit_counting_wd\gitted\logs\HEAD" />
<None Include="Resources\commit_counting_wd\gitted\logs\refs\heads\develop" />
<None Include="Resources\commit_counting_wd\gitted\logs\refs\heads\feature" />
<None Include="Resources\commit_counting_wd\gitted\logs\refs\heads\hotfix-1.2.1" />
<None Include="Resources\commit_counting_wd\gitted\logs\refs\heads\hotfix-1.3.1" />
<None Include="Resources\commit_counting_wd\gitted\logs\refs\heads\master" />
<None Include="Resources\commit_counting_wd\gitted\logs\refs\heads\release-1.3.0" />
<None Include="Resources\commit_counting_wd\gitted\objects\04\91c5dac30d706f4e54c5cb26d082baad8228d1" />
<None Include="Resources\commit_counting_wd\gitted\objects\05\bc4a442c2c04ceadedee7cccc5e0632603e81a" />
<None Include="Resources\commit_counting_wd\gitted\objects\09\bde4792dca146fcae327df52e020c01ae7c234" />
<None Include="Resources\commit_counting_wd\gitted\objects\0b\7a2482ab7d167cefa4ecfc106db001dc5c17ff" />
<None Include="Resources\commit_counting_wd\gitted\objects\10\ddd6d257e01349d514541981aeecea6b2e741d" />
<None Include="Resources\commit_counting_wd\gitted\objects\14\5754f4b45a854df209b0caaf85dacc9da12073" />
<None Include="Resources\commit_counting_wd\gitted\objects\1b\9cff4589e2f37bc624a18c349b7d95c360aaf7" />
<None Include="Resources\commit_counting_wd\gitted\objects\24\3f56dcdb543688fd0a99bd3e0e72dd9a786603" />
<None Include="Resources\commit_counting_wd\gitted\objects\25\3e94347a96fe4a1eab4e47972afd16f6992528" />
<None Include="Resources\commit_counting_wd\gitted\objects\2b\a23b8f9fa44d39579ec460df3d1119f0386c55" />
<None Include="Resources\commit_counting_wd\gitted\objects\32\0f4b6820cf4b0853dc08ac153f04fbd4958200" />
<None Include="Resources\commit_counting_wd\gitted\objects\37\985ac1a12f009b0ebb7138292c1be30393d343" />
<None Include="Resources\commit_counting_wd\gitted\objects\3b\012518e0c89bb753459912738604a915cd70d6" />
<None Include="Resources\commit_counting_wd\gitted\objects\3c\5acc4409d4d1dd9d9bb34c7ec0d030f61efd20" />
<None Include="Resources\commit_counting_wd\gitted\objects\48\79bade90ff18f945a5963b2137a6177255dc1d" />
<None Include="Resources\commit_counting_wd\gitted\objects\4d\65c519f88773854f9345eaf5dbb30cb49f6a74" />
<None Include="Resources\commit_counting_wd\gitted\objects\57\6a28e321cd6dc764b52c5fface672fa076f37f" />
<None Include="Resources\commit_counting_wd\gitted\objects\5b\84136c848fd48f1f8b3fa4e1b767a1f6101279" />
<None Include="Resources\commit_counting_wd\gitted\objects\5d\28d9be43f88fd2e559c8df05d672519fd98def" />
<None Include="Resources\commit_counting_wd\gitted\objects\76\55537837096d925a4f974232f78ec589d86ebd" />
<None Include="Resources\commit_counting_wd\gitted\objects\7b\f37e6d273e6d4d1675b2392c7efc7905e659a1" />
<None Include="Resources\commit_counting_wd\gitted\objects\7f\981d15f0f26fdef40e5ce27fd31245d183c00f" />
<None Include="Resources\commit_counting_wd\gitted\objects\80\979fd11b309d75ba0e449a044eb5bd68f1dbb5" />
<None Include="Resources\commit_counting_wd\gitted\objects\8c\890487ed143d5a72d151e64be1c5ddb314c908" />
<None Include="Resources\commit_counting_wd\gitted\objects\96\eab83bf7e621e5864bdbbf7dca2babc7d782ef" />
<None Include="Resources\commit_counting_wd\gitted\objects\98\0a0d5f19a64b4b30a87d4206aade58726b60e3" />
<None Include="Resources\commit_counting_wd\gitted\objects\99\5f657dd218bbac404f037f9e757553253fadcf" />
<None Include="Resources\commit_counting_wd\gitted\objects\9a\c3b3ad9cc2cad280b8f792be0ae9f11dcd54fd" />
<None Include="Resources\commit_counting_wd\gitted\objects\9e\a56e0287af87d6b80fad6425949ee6a92fd4c8" />
<None Include="Resources\commit_counting_wd\gitted\objects\a2\0830e41b797241be247c3be78dd58844726b1a" />
<None Include="Resources\commit_counting_wd\gitted\objects\a2\af6fa735df44810544c678d8905f29279621b3" />
<None Include="Resources\commit_counting_wd\gitted\objects\b5\3054c614d36edc9d1bee8c35cd2ed575a43607" />
<None Include="Resources\commit_counting_wd\gitted\objects\ba\4c5142cc3836ccd2c913c6c45b1326aaa32a85" />
<None Include="Resources\commit_counting_wd\gitted\objects\bc\bf8b84bd9f843c1d41adbc48605191993c9d64" />
<None Include="Resources\commit_counting_wd\gitted\objects\cc\adf23feaf76eeb160074aa727df2a2db99a2b5" />
<None Include="Resources\commit_counting_wd\gitted\objects\d6\c22a049123e6ad6f6978afcb83c54e7ffe49cd" />
<None Include="Resources\commit_counting_wd\gitted\objects\d8\e9d74ba870d039a1c434f4c849865f9392afba" />
<None Include="Resources\commit_counting_wd\gitted\objects\e4\80263d0b3eeb3a35e6559032a0fdcb9eb19baa" />
<None Include="Resources\commit_counting_wd\gitted\objects\e9\65047ad7c57865823c7d992b1d046ea66edf78" />
<None Include="Resources\commit_counting_wd\gitted\objects\ec\b2da563e05f8b1470ca0358836a828c3a5d3e4" />
<None Include="Resources\commit_counting_wd\gitted\objects\ee\329e1c19d40b05ad157fb1fcc424af9d375f24" />
<None Include="Resources\commit_counting_wd\gitted\objects\fa\b69e28ee35dd912c0c95d5993dd84e4f2bcd92" />
<None Include="Resources\commit_counting_wd\gitted\objects\fc\eb2620f88c2fb6284a08f2b67f9f174afe3b91" />
<None Include="Resources\commit_counting_wd\gitted\refs\heads\develop" />
<None Include="Resources\commit_counting_wd\gitted\refs\heads\feature" />
<None Include="Resources\commit_counting_wd\gitted\refs\heads\hotfix-1.2.1" />
<None Include="Resources\commit_counting_wd\gitted\refs\heads\hotfix-1.3.1" />
<None Include="Resources\commit_counting_wd\gitted\refs\heads\master" />
<None Include="Resources\commit_counting_wd\gitted\refs\heads\release-1.3.0" />
<None Include="Resources\commit_counting_wd\gitted\refs\tags\1.2.0" />
<None Include="Resources\commit_counting_wd\gitted\refs\tags\1.2.1" />
<None Include="Resources\commit_counting_wd\gitted\refs\tags\1.3.0" />
<None Include="Resources\commit_counting_wd\gitted\refs\tags\1.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitVersionCore\GitVersionCore.csproj">
Expand All @@ -102,7 +168,12 @@
<ItemGroup>
<Content Include="FodyWeavers.xml" />
<Content Include="JsonVersionBuilderTests.Json.approved.txt" />
<Content Include="Resources\.gitattributes" />
<Content Include="Resources\commit_counting_wd\another.txt" />
<Content Include="Resources\commit_counting_wd\file.txt" />
<Content Include="Resources\commit_counting_wd\new.txt" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down
61 changes: 61 additions & 0 deletions GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using GitVersion.Configuration;
using LibGit2Sharp;
using NUnit.Framework;

[TestFixture]
public class DevelopScenarios
{
[Test]
public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
{
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.1.0-unstable.0+0");
}
}

[Test]
public void CanChangeDevelopTagViaConfig()
{
using (var fixture = new EmptyRepositoryFixture(new Config
{
DevelopBranchTag = "alpha"
}))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.1.0-alpha.0+0");
}
}

[Test]
public void CanClearDevelopTagViaConfig()
{
using (var fixture = new EmptyRepositoryFixture(new Config
{
DevelopBranchTag = ""
}))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.1.0+0");
}
}

[Test]
public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased()
{
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeACommit();
var commit = fixture.Repository.Head.Tip;
fixture.Repository.MakeACommit();
fixture.Repository.Checkout(commit);
fixture.AssertFullSemver("1.1.0-unstable.1+1");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Shouldly;

[TestFixture]
public class MetaDataByCommitFixture
public class MetaDataByCommitScenarios
{
/*
* hotfix-1.2.1 -----------C--
Expand Down
Loading