diff --git a/GitVersionCore.Tests/ConfigProviderTests.cs b/GitVersionCore.Tests/ConfigProviderTests.cs
index 10c804f2fc..dccdd8da58 100644
--- a/GitVersionCore.Tests/ConfigProviderTests.cs
+++ b/GitVersionCore.Tests/ConfigProviderTests.cs
@@ -88,6 +88,20 @@ public void OverwritesDefaultsWithProvidedConfig()
config.Branches["develop"].Tag.ShouldBe("dev");
}
+ [Test]
+ public void CanProvideConfigForNewBranch()
+ {
+ const string text = @"
+next-version: 2.0.0
+branches:
+ bug[/-]:
+ tag: bugfix";
+ SetupConfigFileContent(text);
+ var config = ConfigurationProvider.Provide(gitDirectory, fileSystem);
+
+ config.Branches["bug[/-]"].Tag.ShouldBe("bugfix");
+ }
+
[Test]
[MethodImpl(MethodImplOptions.NoInlining)]
public void CanWriteOutEffectiveConfiguration()
diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj
index 6d82c56c4f..726a1d4816 100644
--- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj
+++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj
@@ -90,6 +90,7 @@
+
diff --git a/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs b/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs
index b619b77c49..9dc8e7f3f9 100644
--- a/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs
+++ b/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs
@@ -26,21 +26,7 @@ public void CanChangeDevelopTagViaConfig()
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeACommit();
- fixture.AssertFullSemver("1.1.0-alpha.1+1");
- }
- }
-
- [Test]
- public void CanClearDevelopTagViaConfig()
- {
- var config = new Config();
- config.Branches["develop"].Tag = "";
- using (var fixture = new EmptyRepositoryFixture(config))
- {
- fixture.Repository.MakeATaggedCommit("1.0.0");
- fixture.Repository.CreateBranch("develop").Checkout();
- fixture.Repository.MakeACommit();
- fixture.AssertFullSemver("1.1.0+1");
+ fixture.AssertFullSemver("1.1.0-alpha.1");
}
}
@@ -52,7 +38,7 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeACommit();
- fixture.AssertFullSemver("1.1.0-unstable.1+1");
+ fixture.AssertFullSemver("1.1.0-unstable.1");
}
}
@@ -71,7 +57,7 @@ public void MergingReleaseBranchBackIntoDevelopWithMergingToMaster_DoesBumpDevel
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());
- fixture.AssertFullSemver("2.1.0-unstable.1+0");
+ fixture.AssertFullSemver("2.1.0-unstable.0");
}
}
@@ -100,7 +86,7 @@ public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased()
var commit = fixture.Repository.Head.Tip;
fixture.Repository.MakeACommit();
fixture.Repository.Checkout(commit);
- fixture.AssertFullSemver("1.1.0-unstable.1+1");
+ fixture.AssertFullSemver("1.1.0-unstable.1");
}
}
}
\ No newline at end of file
diff --git a/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs b/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs
index fb779337ae..e7e9632667 100644
--- a/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs
+++ b/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs
@@ -33,10 +33,10 @@ public void PatchLatestReleaseExample()
// Verify develop version
fixture.Repository.Checkout("develop");
- fixture.AssertFullSemver("1.3.0-unstable.1+1");
+ fixture.AssertFullSemver("1.3.0-unstable.1");
fixture.Repository.MergeNoFF("hotfix-1.2.1", Constants.SignatureNow());
- fixture.AssertFullSemver("1.3.0-unstable.1+0");
+ fixture.AssertFullSemver("1.3.0-unstable.0");
}
}
@@ -84,9 +84,9 @@ public void PatchOlderReleaseExample()
// Verify develop version
fixture.Repository.Checkout("develop");
- fixture.AssertFullSemver("2.1.0-unstable.1+1");
+ fixture.AssertFullSemver("2.1.0-unstable.1");
fixture.Repository.MergeNoFF("support-1.1", Constants.SignatureNow());
- fixture.AssertFullSemver("2.1.0-unstable.1+7");
+ fixture.AssertFullSemver("2.1.0-unstable.7");
}
}
}
\ No newline at end of file
diff --git a/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs b/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs
index deceda1866..f555e4fd63 100644
--- a/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs
+++ b/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs
@@ -129,7 +129,7 @@ public void WhenReleaseBranchIsMergedIntoDevelopHighestVersionIsTakenWithIt()
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow());
- fixture.AssertFullSemver("2.1.0-unstable.1+5");
+ fixture.AssertFullSemver("2.1.0-unstable.5");
}
}
diff --git a/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs b/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs
index b7f827d8ce..8dc12a3a77 100644
--- a/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs
+++ b/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs
@@ -14,7 +14,7 @@ public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReac
fixture.Repository.MakeATaggedCommit("1.0.0.0");
fixture.Repository.MakeCommits(2);
fixture.Repository.CreateBranch("develop").Checkout();
- fixture.AssertFullSemver("1.1.0-unstable.1+2");
+ fixture.AssertFullSemver("1.1.0-unstable.2");
}
}
}
\ No newline at end of file
diff --git a/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs b/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs
new file mode 100644
index 0000000000..352e7afc8a
--- /dev/null
+++ b/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs
@@ -0,0 +1,21 @@
+using GitVersion;
+using NUnit.Framework;
+
+[TestFixture]
+public class VersionBumpingScenarios
+{
+ [Test]
+ public void AppliedPrereleaseTagCausesBump()
+ {
+ var configuration = new Config();
+ configuration.Branches["master"].Tag = "pre";
+ using (var fixture = new EmptyRepositoryFixture(configuration))
+ {
+ fixture.Repository.MakeACommit();
+ fixture.Repository.MakeATaggedCommit("1.0.0-pre.1");
+ fixture.Repository.MakeACommit();
+
+ fixture.AssertFullSemver("1.0.0-pre.2+1");
+ }
+ }
+}
diff --git a/GitVersionCore.Tests/IntegrationTests/WikiScenarios.cs b/GitVersionCore.Tests/IntegrationTests/WikiScenarios.cs
index c57de383ab..30b9ac81a2 100644
--- a/GitVersionCore.Tests/IntegrationTests/WikiScenarios.cs
+++ b/GitVersionCore.Tests/IntegrationTests/WikiScenarios.cs
@@ -45,7 +45,7 @@ public void MinorReleaseExample()
// Branch to develop
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeACommit();
- fixture.AssertFullSemver("1.3.0-unstable.1+1");
+ fixture.AssertFullSemver("1.3.0-unstable.1");
// Open Pull Request
fixture.Repository.CreateBranch("pull/2/merge").Checkout();
@@ -56,7 +56,7 @@ public void MinorReleaseExample()
// Merge into develop
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("pull/2/merge", Constants.SignatureNow());
- fixture.AssertFullSemver("1.3.0-unstable.1+3");
+ fixture.AssertFullSemver("1.3.0-unstable.3");
// Create release branch
fixture.Repository.CreateBranch("release-1.3.0").Checkout();
@@ -65,7 +65,7 @@ public void MinorReleaseExample()
// Make another commit on develop
fixture.Repository.Checkout("develop");
fixture.Repository.MakeACommit();
- fixture.AssertFullSemver("1.3.0-unstable.1+4");
+ fixture.AssertFullSemver("1.3.0-unstable.4");
// Make a commit to release-1.3.0
fixture.Repository.Checkout("release-1.3.0");
@@ -89,7 +89,7 @@ public void MinorReleaseExample()
// Verify develop version
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
- fixture.AssertFullSemver("1.4.0-unstable.1+0");
+ fixture.AssertFullSemver("1.4.0-unstable.0");
}
}
}
\ No newline at end of file
diff --git a/GitVersionCore.Tests/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt b/GitVersionCore.Tests/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt
index 28ca6e078c..47b48fc15d 100644
--- a/GitVersionCore.Tests/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt
+++ b/GitVersionCore.Tests/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt
@@ -11,8 +11,8 @@
"LegacySemVer":"1.2.3-unstable5",
"LegacySemVerPadded":"1.2.3-unstable0005",
"AssemblySemVer":"1.2.3.0",
- "FullSemVer":"1.2.3-unstable.5+4",
- "InformationalVersion":"1.2.3-unstable.5+4.Branch.develop.Sha.commitSha",
+ "FullSemVer":"1.2.3-unstable.5",
+ "InformationalVersion":"1.2.3-unstable.5+Branch.develop.Sha.commitSha",
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0005",
diff --git a/GitVersionCore/BranchConfigurationCalculator.cs b/GitVersionCore/BranchConfigurationCalculator.cs
index 91bf3d1e1b..510c9833cd 100644
--- a/GitVersionCore/BranchConfigurationCalculator.cs
+++ b/GitVersionCore/BranchConfigurationCalculator.cs
@@ -39,7 +39,7 @@ static KeyValuePair InheritBranchConfiguration(
BranchConfig branchConfiguration, Config config)
{
Logger.WriteInfo("Attempting to inherit branch configuration from parent branch");
- var excludedBranches = new Branch[0];
+ var excludedBranches = new [] { currentBranch };
// Check if we are a merge commit. If so likely we are a pull request
var parentCount = currentCommit.Parents.Count();
if (parentCount == 2)
@@ -68,15 +68,12 @@ static KeyValuePair InheritBranchConfiguration(
List possibleParents;
if (branchPoint.Sha == currentCommit.Sha)
{
- possibleParents = ListBranchesContaininingCommit(repository, currentCommit.Sha, excludedBranches).Except(new[]
- {
- currentBranch
- }).ToList();
+ possibleParents = currentCommit.GetBranchesContainingCommit(repository, true).Except(excludedBranches).ToList();
}
else
{
- var branches = ListBranchesContaininingCommit(repository, branchPoint.Sha, excludedBranches).ToList();
- var currentTipBranches = ListBranchesContaininingCommit(repository, currentCommit.Sha, excludedBranches).ToList();
+ var branches = branchPoint.GetBranchesContainingCommit(repository, true).Except(excludedBranches).ToList();
+ var currentTipBranches = currentCommit.GetBranchesContainingCommit(repository, true).Except(excludedBranches).ToList();
possibleParents = branches
.Except(currentTipBranches)
.ToList();
@@ -119,14 +116,5 @@ static KeyValuePair InheritBranchConfiguration(
Increment = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, repository.Branches[branchName]).Value.Increment
});
}
-
- static IEnumerable ListBranchesContaininingCommit(IRepository repo, string commitSha, Branch[] excludedBranches)
- {
- return from branch in repo.Branches.Except(excludedBranches)
- where !branch.IsRemote
- let commits = repo.Commits.QueryBy(new CommitFilter { Since = branch }).Where(c => c.Sha == commitSha)
- where commits.Any()
- select branch;
- }
}
}
\ No newline at end of file
diff --git a/GitVersionCore/Configuration/Config.cs b/GitVersionCore/Configuration/Config.cs
index a515369659..6987821fc5 100644
--- a/GitVersionCore/Configuration/Config.cs
+++ b/GitVersionCore/Configuration/Config.cs
@@ -72,7 +72,13 @@ public Dictionary Branches
}
set
{
- value.ToList().ForEach(_ => branches[_.Key] = MergeObjects(branches[_.Key], _.Value));
+ value.ToList().ForEach(_ =>
+ {
+ if (!branches.ContainsKey(_.Key))
+ branches.Add(_.Key, new BranchConfig());
+
+ branches[_.Key] = MergeObjects(branches[_.Key], _.Value);
+ });
}
}
diff --git a/GitVersionCore/Configuration/ConfigSerialiser.cs b/GitVersionCore/Configuration/ConfigSerialiser.cs
index cb40bd3b4a..bee615e0d9 100644
--- a/GitVersionCore/Configuration/ConfigSerialiser.cs
+++ b/GitVersionCore/Configuration/ConfigSerialiser.cs
@@ -31,8 +31,8 @@ public static void WriteSample(TextWriter writer)
writer.WriteLine("# mode: ContinuousDelivery | ContinuousDeployment");
writer.WriteLine("# continuous-delivery-fallback-tag: ci");
writer.WriteLine("#branches:");
- writer.WriteLine("# release[/-]*:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: rc");
- writer.WriteLine("# develop:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: alpha");
+ writer.WriteLine("# release[/-]:\n mode: ContinuousDelivery | ContinuousDeployment\n tag: rc");
+ writer.WriteLine("# develop:\n# mode: ContinuousDelivery | ContinuousDeployment\n# tag: alpha");
}
}
}
\ No newline at end of file
diff --git a/GitVersionCore/GitVersionContext.cs b/GitVersionCore/GitVersionContext.cs
index 3591848275..3ad1f2d8a0 100644
--- a/GitVersionCore/GitVersionContext.cs
+++ b/GitVersionCore/GitVersionContext.cs
@@ -60,10 +60,8 @@ public GitVersionContext(IRepository repository, Branch currentBranch, Config co
void CalculateEffectiveConfiguration()
{
var currentBranchConfig = BranchConfigurationCalculator.GetBranchConfiguration(CurrentCommit, Repository, OnlyEvaluateTrackedBranches, configuration, CurrentBranch);
-
- // Versioning mode drills down, if top level is specified then it takes priority
- var versioningMode = configuration.VersioningMode ?? currentBranchConfig.Value.VersioningMode ?? VersioningMode.ContinuousDelivery;
-
+
+ var versioningMode = currentBranchConfig.Value.VersioningMode ?? configuration.VersioningMode ?? VersioningMode.ContinuousDelivery;
var tag = currentBranchConfig.Value.Tag ?? "useBranchName";
var nextVersion = configuration.NextVersion;
var incrementStrategy = currentBranchConfig.Value.Increment ?? IncrementStrategy.Patch;
diff --git a/GitVersionCore/OutputVariables/VariableProvider.cs b/GitVersionCore/OutputVariables/VariableProvider.cs
index bfbf034d47..8e9bc04c5a 100644
--- a/GitVersionCore/OutputVariables/VariableProvider.cs
+++ b/GitVersionCore/OutputVariables/VariableProvider.cs
@@ -18,9 +18,8 @@ public static VersionVariables GetVariablesFor(
}
// For continuous deployment the commits since tag gets promoted to the pre-release number
- var oldPreReleaseNumber = semanticVersion.PreReleaseTag.Number;
semanticVersion.PreReleaseTag.Number = semanticVersion.BuildMetaData.CommitsSinceTag;
- semanticVersion.BuildMetaData.CommitsSinceTag = oldPreReleaseNumber;
+ semanticVersion.BuildMetaData.CommitsSinceTag = null;
}
var variables = new VersionVariables(
diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt
index 5b713f2e15..1a05967dbf 100644
--- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt
+++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt
@@ -3,7 +3,7 @@ using System;
using System.Reflection;
[assembly: AssemblyVersion("2.0.0.0")]
-[assembly: AssemblyFileVersion("2.0.0.0")]
+[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: AssemblyInformationalVersion("2.3.4+5.Branch.master.Sha.commitSha")]
[assembly: ReleaseDate("2014-03-06")]
diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt
index fd72432035..d511ebdaf9 100644
--- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt
+++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt
@@ -3,7 +3,7 @@ using System;
using System.Reflection;
[assembly: AssemblyVersion("2.3.0.0")]
-[assembly: AssemblyFileVersion("2.3.0.0")]
+[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: AssemblyInformationalVersion("2.3.4+5.Branch.master.Sha.commitSha")]
[assembly: ReleaseDate("2014-03-06")]
diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt
index e3c6ccf659..8db12fa50a 100644
--- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt
+++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt
@@ -3,7 +3,7 @@ using System;
using System.Reflection;
[assembly: AssemblyVersion("2.3.4.5")]
-[assembly: AssemblyFileVersion("2.3.4.5")]
+[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: AssemblyInformationalVersion("2.3.4+5.Branch.master.Sha.commitSha")]
[assembly: ReleaseDate("2014-03-06")]
diff --git a/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs b/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs
index 3e97e63600..bcfc1d6647 100644
--- a/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs
+++ b/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs
@@ -37,8 +37,9 @@ static class GitVersionInformation
}}
-", vars.AssemblySemVer,
- vars.AssemblySemVer,
+",
+vars.AssemblySemVer,
+ vars.MajorMinorPatch + ".0",
semanticVersion.ToString("i"),
semanticVersion.BuildMetaData.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"),
GenerateVariableMembers(vars));