diff --git a/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs b/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs index eb42637e57..87af5373be 100644 --- a/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs +++ b/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs @@ -72,4 +72,21 @@ public void CanCalculatePullRequestChangesInheritingConfigFromRemoteRepo() fixture.AssertFullSemver("0.2.0-PullRequest.2+3"); } } + + [Test] + public void CalculatesCorrectVersionAfterReleaseBranchMergedToMaster() + { + using (var fixture = new EmptyRepositoryFixture(new Config())) + { + fixture.Repository.MakeATaggedCommit("1.0.0"); + fixture.Repository.MakeACommit(); + fixture.Repository.CreateBranch("release/2.0.0").Checkout(); + fixture.Repository.MakeACommit(); + fixture.Repository.MakeACommit(); + + fixture.Repository.CreatePullRequest("release/2.0.0", "master"); + + fixture.AssertFullSemver("2.0.0-PullRequest.2+0"); + } + } } \ No newline at end of file diff --git a/GitVersionCore/BranchConfigurationCalculator.cs b/GitVersionCore/BranchConfigurationCalculator.cs index 510c9833cd..7955cece50 100644 --- a/GitVersionCore/BranchConfigurationCalculator.cs +++ b/GitVersionCore/BranchConfigurationCalculator.cs @@ -89,11 +89,13 @@ static KeyValuePair InheritBranchConfiguration( if (possibleParents.Count == 1) { + var branchConfig = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, possibleParents[0]).Value; return new KeyValuePair( keyValuePair.Key, new BranchConfig(branchConfiguration) { - Increment = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, possibleParents[0]).Value.Increment + Increment = branchConfig.Increment, + PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion }); } @@ -109,11 +111,13 @@ static KeyValuePair InheritBranchConfiguration( var branchName = hasDevelop ? "develop" : "master"; Logger.WriteWarning(errorMessage + Environment.NewLine + Environment.NewLine + "Falling back to " + branchName + " branch config"); + var value = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, repository.Branches[branchName]).Value; return new KeyValuePair( keyValuePair.Key, new BranchConfig(branchConfiguration) { - Increment = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, repository.Branches[branchName]).Value.Increment + Increment = value.Increment, + PreventIncrementOfMergedBranchVersion = value.PreventIncrementOfMergedBranchVersion }); } }