From ced5907e75bf2a00a5aec699640f6bb0ba7bce1a Mon Sep 17 00:00:00 2001 From: Timothy Barnett TIBA Date: Mon, 31 Jul 2017 13:39:53 +0200 Subject: [PATCH] Allow branch names starting with master _masterfix_ and _fixmaster_ now behave the same way (i.e. in a different way to _master_, but in the same way as other branches) --- .../IntegrationTests/OtherScenarios.cs | 14 ++++++++++++++ src/GitVersionCore/Configuration/Config.cs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs index 4ebda3317b..5fef1447c6 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs @@ -46,6 +46,20 @@ public void AllowNotHavingMaster() } } + [Test] + public void AllowHavingVariantsStartingWithMaster() + { + using (var fixture = new EmptyRepositoryFixture()) + { + fixture.Repository.MakeACommit(); + fixture.Repository.MakeATaggedCommit("1.0.0"); + fixture.Repository.MakeACommit(); + Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("masterfix")); + + fixture.AssertFullSemver("1.0.1-masterfix.1+1"); + } + } + [Test] public void AllowHavingMainInsteadOfMaster() { diff --git a/src/GitVersionCore/Configuration/Config.cs b/src/GitVersionCore/Configuration/Config.cs index a5d6dcecf8..4b822327e9 100644 --- a/src/GitVersionCore/Configuration/Config.cs +++ b/src/GitVersionCore/Configuration/Config.cs @@ -95,7 +95,7 @@ public BranchConfig GetConfigForBranch(string branchName) { if (branchName == null) throw new ArgumentNullException(nameof(branchName)); var matches = Branches - .Where(b => Regex.IsMatch(branchName, "^" + b.Value.Regex, RegexOptions.IgnoreCase)); + .Where(b => Regex.IsMatch(branchName, "^" + b.Value.Regex + "$", RegexOptions.IgnoreCase)); try {