Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ We love contributions to get started contributing you might need:

- [Get started with git](http://rogerdudler.github.io/git-guide)
- [How to create a pull request](https://help.github.com/articles/using-pull-requests)
- [An issue to work on](https://github.com/ParticularLabs/GitVersion/labels/up-for-grabs) - We are on [Up for grabs](http://up-for-grabs.net/), our up for grabs issues are tagged `up-for-grabs`
- [An issue to work on](https://github.com/GitTools/GitVersion/labels/up-for-grabs) - We are on [Up for grabs](http://up-for-grabs.net/), our up for grabs issues are tagged `up-for-grabs`
- An understanding of our [architecture](#architecture) and how [we write tests](#writing-tests)

Once you know how to create a pull request and have an issue to work on, just post a comment saying you will work on it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDelivery
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: ci
branches:
master:
tag:
increment: Patch
prevent-increment-of-merged-branch-version: true
release[/-]:
tag: beta
feature[/-]:
tag: useBranchName
increment: Inherit
hotfix[/-]:
tag: beta
support[/-]:
tag:
increment: Patch
prevent-increment-of-merged-branch-version: true
develop:
mode: ContinuousDeployment
tag: unstable
increment: Minor
track-merge-target: true
(pull|pull\-requests|pr)[/-]:
tag: PullRequest
increment: Inherit
tag-number-pattern: '[/-](?<number>\d+)[-/]'
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDelivery
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: ci
branches:
master:
mode: ContinuousDelivery
tag:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
release[/-]:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
feature[/-]:
mode: ContinuousDelivery
tag: useBranchName
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
(pull|pull\-requests|pr)[/-]:
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
hotfix[/-]:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
support[/-]:
mode: ContinuousDelivery
tag:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
develop:
mode: ContinuousDeployment
tag: unstable
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
9 changes: 4 additions & 5 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,24 @@ public void CanReadOldDocument()
var error = Should.Throw<OldConfigurationException>(() => ConfigurationProvider.Provide(repoPath, fileSystem));
error.Message.ShouldContainWithoutWhitespace(@"GitVersionConfig.yaml contains old configuration, please fix the following errors:
assemblyVersioningScheme has been replaced by assembly-versioning-scheme
develop-branch-tag has been replaced by branch specific configuration.See https://github.com/ParticularLabs/GitVersion/wiki/Branch-Specific-Configuration
release-branch-tag has been replaced by branch specific configuration.See https://github.com/ParticularLabs/GitVersion/wiki/Branch-Specific-Configuration");
develop-branch-tag has been replaced by branch specific configuration.See http://gitversion.readthedocs.org/en/latest/configuration/#branch-configuration
release-branch-tag has been replaced by branch specific configuration.See http://gitversion.readthedocs.org/en/latest/configuration/#branch-configuration");
}

[Test]
public void OverwritesDefaultsWithProvidedConfig()
{
var defaultConfig = ConfigurationProvider.Provide(repoPath, fileSystem);
const string text = @"
next-version: 2.0.0
branches:
develop:
mode: ContinuousDeployment
tag: dev";
SetupConfigFileContent(text);
var defaultConfig = new Config();
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.NextVersion.ShouldBe("2.0.0");
config.AssemblyVersioningScheme.ShouldBe(defaultConfig.AssemblyVersioningScheme);
config.Branches["develop"].Increment.ShouldBe(defaultConfig.Branches["develop"].Increment);
config.Branches["develop"].VersioningMode.ShouldBe(defaultConfig.Branches["develop"].VersioningMode);
config.Branches["develop"].Tag.ShouldBe("dev");
Expand Down Expand Up @@ -120,7 +119,7 @@ public void CanReadDefaultDocument()
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
config.Branches["develop"].Tag.ShouldBe("unstable");
config.Branches["release[/-]"].Tag.ShouldBe("beta");
config.TagPrefix.ShouldBe(Config.DefaultTagPrefix);
config.TagPrefix.ShouldBe(ConfigurationProvider.DefaultTagPrefix);
config.NextVersion.ShouldBe(null);
}

Expand Down
1 change: 1 addition & 0 deletions src/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public abstract class RepositoryFixtureBase : IDisposable

protected RepositoryFixtureBase(Func<string, IRepository> repoBuilder, Config configuration)
{
ConfigurationProvider.ApplyDefaultsTo(configuration);
diagramBuilder = new StringBuilder();
diagramBuilder.AppendLine("@startuml");
this.configuration = configuration;
Expand Down
4 changes: 3 additions & 1 deletion src/GitVersionCore.Tests/GitVersionContextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public GitVersionContextBuilder AddBranch(string branchName)

public GitVersionContext Build()
{
return new GitVersionContext(repository ?? CreateRepository(), config ?? new Config());
var configuration = config ?? new Config();
ConfigurationProvider.ApplyDefaultsTo(configuration);
return new GitVersionContext(repository ?? CreateRepository(), configuration);
}

IRepository CreateRepository()
Expand Down
27 changes: 21 additions & 6 deletions src/GitVersionCore.Tests/GitVersionContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void CanInheritVersioningMode(VersioningMode mode)
{
VersioningMode = mode
};
ConfigurationProvider.ApplyDefaultsTo(config);

var mockBranch = new MockBranch("master") { new MockCommit { CommitterEx = SignatureBuilder.SignatureNow() } };
var mockRepository = new MockRepository
Expand All @@ -34,10 +35,19 @@ public void UsesBranchSpecificConfigOverTopLevelDefaults()
{
var config = new Config
{
VersioningMode = VersioningMode.ContinuousDelivery
VersioningMode = VersioningMode.ContinuousDelivery,
Branches =
{
{
"develop", new BranchConfig
{
VersioningMode = VersioningMode.ContinuousDeployment,
Tag = "alpha"
}
}
}
};
config.Branches["develop"].VersioningMode = VersioningMode.ContinuousDeployment;
config.Branches["develop"].Tag = "alpha";
ConfigurationProvider.ApplyDefaultsTo(config);
var develop = new MockBranch("develop") { new MockCommit { CommitterEx = SignatureBuilder.SignatureNow() } };
var mockRepository = new MockRepository
{
Expand All @@ -54,9 +64,14 @@ public void UsesBranchSpecificConfigOverTopLevelDefaults()
[Test]
public void CanFindParentBranchForInheritingIncrementStrategy()
{
var config = new Config();
config.Branches["develop"].Increment = IncrementStrategy.Major;
config.Branches["feature[/-]"].Increment = IncrementStrategy.Inherit;
var config = new Config
{
Branches =
{
{ "develop", new BranchConfig { Increment = IncrementStrategy.Major} },
{ "feature[/-]", new BranchConfig { Increment = IncrementStrategy.Inherit} }
}
};

using (var repo = new EmptyRepositoryFixture(config))
{
Expand Down
24 changes: 24 additions & 0 deletions src/GitVersionCore.Tests/GitVersionCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.20.1.0\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
Expand All @@ -68,6 +84,10 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TestStack.ConventionTests, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TestStack.ConventionTests.2.2.1\lib\net40\TestStack.ConventionTests.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="YamlDotNet, Version=3.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\YamlDotNet.3.5.1\lib\net35\YamlDotNet.dll</HintPath>
Expand All @@ -85,6 +105,9 @@
<Compile Include="Fixtures\BaseGitFlowRepositoryFixture.cs" />
<Compile Include="GitVersionContextTests.cs" />
<Compile Include="Helpers\DirectoryHelper.cs" />
<Compile Include="Init\InitScenarios.cs" />
<Compile Include="Init\InitStepsDefaultResponsesDoNotThrow.cs" />
<Compile Include="Init\TestConsole.cs" />
<Compile Include="IntegrationTests\OtherScenarios.cs" />
<Compile Include="IntegrationTests\PullRequestScenarios.cs" />
<Compile Include="IntegrationTests\RemoteRepositoryScenarios.cs" />
Expand Down Expand Up @@ -124,6 +147,7 @@
<Compile Include="SemanticVersionTests.cs" />
<Compile Include="TestEffectiveConfiguration.cs" />
<Compile Include="TestFileSystem.cs" />
<Compile Include="TestStream.cs" />
<Compile Include="VariableProviderTests.cs" />
<Compile Include="VersionCalculation\BaseVersionCalculatorTests.cs" />
<Compile Include="VersionCalculation\NextVersionCalculatorTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
next-version: 2.0.0
branches: {}
31 changes: 31 additions & 0 deletions src/GitVersionCore.Tests/Init/InitScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace GitVersionCore.Tests.Init
{
using ApprovalTests;
using GitVersion;
using GitVersion.Configuration.Init;
using GitVersion.Configuration.Init.Wizard;
using NUnit.Framework;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;

[TestFixture]
public class InitScenarios
{
[Test]
public void CanSetNextVersion()
{
var testFileSystem = new TestFileSystem();
var testConsole = new TestConsole("3", "2.0.0", "0");
ConfigurationProvider.Init("c:\\proj", testFileSystem, testConsole);

Approvals.Verify(testFileSystem.ReadAllText("c:\\proj\\GitVersionConfig.yaml"));
}

[Test]
public void DefaultResponsesDoNotThrow()
{
var steps = Types.InAssemblyOf<EditConfigStep>(t => t.IsSubclassOf(typeof(ConfigInitWizardStep)) && t.IsConcreteClass());
Convention.Is(new InitStepsDefaultResponsesDoNotThrow(), steps);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace GitVersionCore.Tests.Init
{
using System;
using System.Linq;
using System.Reflection;
using GitVersion.Configuration.Init.Wizard;
using TestStack.ConventionTests;
using TestStack.ConventionTests.ConventionData;

public class InitStepsDefaultResponsesDoNotThrow : IConvention<Types>
{
public void Execute(Types data, IConventionResultContext result)
{
var resultProperty = typeof(ConfigInitWizardStep).GetProperty("DefaultResult", BindingFlags.NonPublic | BindingFlags.Instance);
result
.Is("Init steps default response should not throw",
data.TypesToVerify.Where(t =>
{
var constructorInfo = t.GetConstructors().Single();
var ctorArguments = constructorInfo.GetParameters().Select(p => p.ParameterType.IsValueType ? Activator.CreateInstance(p.ParameterType) : null).ToArray();
var instance = Activator.CreateInstance(t, ctorArguments);
try
{
resultProperty.GetValue(instance);
}
catch (Exception)
{
return true;
}
return false;
}));
}

public string ConventionReason { get { return "So things do not blow up"; } }
}
}
46 changes: 46 additions & 0 deletions src/GitVersionCore.Tests/Init/TestConsole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace GitVersionCore.Tests.Init
{
using System;
using System.Collections.Generic;
using GitVersion;

public class TestConsole : IConsole
{
readonly Queue<string> responses;

public TestConsole(params string[] responses)
{
this.responses = new Queue<string>(responses);
}

public void WriteLine(string msg)
{
Logger.WriteInfo(msg + Environment.NewLine);
}

public void WriteLine()
{
Logger.WriteInfo(Environment.NewLine);
}

public void Write(string msg)
{
Logger.WriteInfo(msg);
}

public string ReadLine()
{
return responses.Dequeue();
}

public IDisposable UseColor(ConsoleColor consoleColor)
{
return new NoOpDisposable();
}

class NoOpDisposable : IDisposable
{
public void Dispose() { }
}
}
}
18 changes: 14 additions & 4 deletions src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ public void WhenDevelopBranchedFromTaggedCommitOnMasterVersionDoesNotChange()
[Test]
public void CanChangeDevelopTagViaConfig()
{
var config = new Config();
config.Branches["develop"].Tag = "alpha";
var config = new Config
{
Branches =
{
{ "develop", new BranchConfig { Tag = "alpha" } }
}
};
using (var fixture = new EmptyRepositoryFixture(config))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
Expand Down Expand Up @@ -100,8 +105,13 @@ public void MergingReleaseBranchBackIntoDevelopWithMergingToMaster_DoesBumpDevel
[Test]
public void CanHandleContinuousDelivery()
{
var config = new Config();
config.Branches["develop"].VersioningMode = VersioningMode.ContinuousDelivery;
var config = new Config
{
Branches =
{
{ "develop", new BranchConfig { VersioningMode = VersioningMode.ContinuousDelivery} }
}
};
using (var fixture = new EmptyRepositoryFixture(config))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
Expand Down
Loading