diff --git a/docs/configuration.md b/docs/configuration.md index 217041adbd..f96b6ea4ee 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -189,7 +189,7 @@ If you have branch specific configuration upgrading to v4 will force you to upgr ```yaml branches: master: - regex: master + regex: ^master mode: ContinuousDelivery tag: '' increment: Patch @@ -198,7 +198,7 @@ branches: tracks-release-branches: false is-release-branch: false release: - regex: releases?[/-] + regex: ^releases?[/-] mode: ContinuousDelivery tag: beta increment: Patch @@ -207,7 +207,7 @@ branches: tracks-release-branches: false is-release-branch: true feature: - regex: features?[/-] + regex: ^features?[/-] mode: ContinuousDelivery tag: useBranchName increment: Inherit @@ -216,7 +216,7 @@ branches: tracks-release-branches: false is-release-branch: false pull-request: - regex: (pull|pull\-requests|pr)[/-] + regex: ^(pull|pull\-requests|pr)[/-] mode: ContinuousDelivery tag: PullRequest increment: Inherit @@ -226,7 +226,7 @@ branches: tracks-release-branches: false is-release-branch: false hotfix: - regex: hotfix(es)?[/-] + regex: ^hotfix(es)?[/-] mode: ContinuousDelivery tag: beta increment: Patch @@ -235,7 +235,7 @@ branches: tracks-release-branches: false is-release-branch: false support: - regex: support[/-] + regex: ^support[/-] mode: ContinuousDelivery tag: '' increment: Patch @@ -244,7 +244,7 @@ branches: tracks-release-branches: false is-release-branch: false develop: - regex: dev(elop)?(ment)?$ + regex: ^dev(elop)?(ment)?$ mode: ContinuousDeployment tag: unstable increment: Minor diff --git a/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt b/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt index 2650aedd2b..7d0d4f02a6 100644 --- a/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt +++ b/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt @@ -18,7 +18,7 @@ branches: increment: Minor prevent-increment-of-merged-branch-version: false track-merge-target: true - regex: dev(elop)?(ment)?$ + regex: ^dev(elop)?(ment)?$ source-branches: [] tracks-release-branches: true is-release-branch: false @@ -29,7 +29,7 @@ branches: increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - regex: master$ + regex: ^master$ source-branches: - develop - release @@ -42,7 +42,7 @@ branches: increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - regex: releases?[/-] + regex: ^releases?[/-] source-branches: - develop - master @@ -57,7 +57,7 @@ branches: increment: Inherit prevent-increment-of-merged-branch-version: false track-merge-target: false - regex: features?[/-] + regex: ^features?[/-] source-branches: - develop - master @@ -75,7 +75,7 @@ branches: prevent-increment-of-merged-branch-version: false tag-number-pattern: '[/-](?\d+)' track-merge-target: false - regex: (pull|pull\-requests|pr)[/-] + regex: ^(pull|pull\-requests|pr)[/-] source-branches: - develop - master @@ -92,7 +92,7 @@ branches: increment: Patch prevent-increment-of-merged-branch-version: false track-merge-target: false - regex: hotfix(es)?[/-] + regex: ^hotfix(es)?[/-] source-branches: - develop - master @@ -106,7 +106,7 @@ branches: increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - regex: support[/-] + regex: ^support[/-] source-branches: - master tracks-release-branches: false diff --git a/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs index 72d9029b9e..9f505afbf4 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs @@ -1,4 +1,4 @@ -using GitTools.Testing; +using GitTools.Testing; using GitVersion; using GitVersionCore.Tests; using LibGit2Sharp; @@ -183,4 +183,25 @@ public void InheritVersionFromReleaseBranch() fixture.AssertFullSemver("2.1.0-MyFeature.1+5"); } } -} \ No newline at end of file + + [Test] + public void WhenMultipleDevelopBranchesExistAndCurrentBranchHasIncrementInheritPolicyAndCurrentCommitIsAMerge() + { + using (var fixture = new EmptyRepositoryFixture()) + { + fixture.Repository.MakeATaggedCommit("1.0.0"); + fixture.Repository.CreateBranch("bob_develop"); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.CreateBranch("feature/x"); + + Commands.Checkout(fixture.Repository, "develop"); + fixture.Repository.MakeACommit(); + + Commands.Checkout(fixture.Repository, "feature/x"); + fixture.Repository.MakeACommit(); + fixture.Repository.MergeNoFF("develop"); + + fixture.AssertFullSemver("1.0.1-x.1+3"); + } + } +} diff --git a/src/GitVersionCore/Configuration/Config.cs b/src/GitVersionCore/Configuration/Config.cs index ba04dff821..ab2ac963b2 100644 --- a/src/GitVersionCore/Configuration/Config.cs +++ b/src/GitVersionCore/Configuration/Config.cs @@ -101,7 +101,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 { diff --git a/src/GitVersionCore/Configuration/ConfigurationProvider.cs b/src/GitVersionCore/Configuration/ConfigurationProvider.cs index 796ecc9424..b6c6ae38a4 100644 --- a/src/GitVersionCore/Configuration/ConfigurationProvider.cs +++ b/src/GitVersionCore/Configuration/ConfigurationProvider.cs @@ -14,13 +14,13 @@ public class ConfigurationProvider public const string DefaultConfigFileName = "GitVersion.yml"; public const string ObsoleteConfigFileName = "GitVersionConfig.yaml"; - public const string ReleaseBranchRegex = "releases?[/-]"; - public const string FeatureBranchRegex = "features?[/-]"; - public const string PullRequestRegex = @"(pull|pull\-requests|pr)[/-]"; - public const string HotfixBranchRegex = "hotfix(es)?[/-]"; - public const string SupportBranchRegex = "support[/-]"; - public const string DevelopBranchRegex = "dev(elop)?(ment)?$"; - public const string MasterBranchRegex = "master$"; + public const string ReleaseBranchRegex = "^releases?[/-]"; + public const string FeatureBranchRegex = "^features?[/-]"; + public const string PullRequestRegex = @"^(pull|pull\-requests|pr)[/-]"; + public const string HotfixBranchRegex = "^hotfix(es)?[/-]"; + public const string SupportBranchRegex = "^support[/-]"; + public const string DevelopBranchRegex = "^dev(elop)?(ment)?$"; + public const string MasterBranchRegex = "^master$"; public const string MasterBranchKey = "master"; public const string ReleaseBranchKey = "release"; public const string FeatureBranchKey = "feature"; diff --git a/src/GitVersionCore/Configuration/LegacyConfigNotifier.cs b/src/GitVersionCore/Configuration/LegacyConfigNotifier.cs index 2086255579..00ba347cc3 100644 --- a/src/GitVersionCore/Configuration/LegacyConfigNotifier.cs +++ b/src/GitVersionCore/Configuration/LegacyConfigNotifier.cs @@ -17,7 +17,8 @@ public class LegacyConfigNotifier {ConfigurationProvider.ReleaseBranchRegex, ConfigurationProvider.ReleaseBranchKey}, {ConfigurationProvider.SupportBranchRegex, ConfigurationProvider.SupportBranchKey}, {ConfigurationProvider.PullRequestRegex, ConfigurationProvider.PullRequestBranchKey}, - {"release[/-]", ConfigurationProvider.ReleaseBranchKey}, + {"dev(elop)?(ment)?$", ConfigurationProvider.DevelopBranchKey }, + {"release[/-]", ConfigurationProvider.ReleaseBranchKey }, {"hotfix[/-]", ConfigurationProvider.HotfixBranchKey }, {"feature(s)?[/-]", ConfigurationProvider.FeatureBranchKey }, {"feature[/-]", ConfigurationProvider.FeatureBranchKey }