diff --git a/src/GitVersionCore/BranchConfigurationCalculator.cs b/src/GitVersionCore/BranchConfigurationCalculator.cs index 35215d5a42..471f8560e8 100644 --- a/src/GitVersionCore/BranchConfigurationCalculator.cs +++ b/src/GitVersionCore/BranchConfigurationCalculator.cs @@ -8,6 +8,8 @@ namespace GitVersion public class BranchConfigurationCalculator { + public static string FallbackConfigName = "Fallback"; + /// /// Gets the for the current commit. /// @@ -21,7 +23,7 @@ public static BranchConfig GetBranchConfiguration(GitVersionContext context, Bra "No branch configuration found for branch {0}, falling back to default configuration", targetBranch.FriendlyName)); - matchingBranches = new BranchConfig { Name = string.Empty }; + matchingBranches = new BranchConfig { Name = FallbackConfigName }; ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, matchingBranches, "", new List()); } @@ -65,7 +67,7 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch List possibleParents; if (branchPoint == BranchCommit.Empty) { - possibleParents = context.RepositoryMetadataProvider.GetBranchesContainingCommit(context.CurrentCommit, branchesToEvaluate, true) + possibleParents = context.RepositoryMetadataProvider.GetBranchesContainingCommit(targetBranch.Tip, branchesToEvaluate, true) // It fails to inherit Increment branch configuration if more than 1 parent; // therefore no point to get more than 2 parents .Take(2) @@ -135,9 +137,15 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch } var inheritingBranchConfig = GetBranchConfiguration(context, chosenBranch, excludedInheritBranches); + var configIncrement = inheritingBranchConfig.Increment; + if (inheritingBranchConfig.Name == FallbackConfigName && configIncrement == IncrementStrategy.Inherit) + { + Logger.WriteWarning("Fallback config inherits by default, dropping to patch increment"); + configIncrement = IncrementStrategy.Patch; + } return new BranchConfig(branchConfiguration) { - Increment = inheritingBranchConfig.Increment, + Increment = configIncrement, PreventIncrementOfMergedBranchVersion = inheritingBranchConfig.PreventIncrementOfMergedBranchVersion, // If we are inheriting from develop then we should behave like develop TracksReleaseBranches = inheritingBranchConfig.TracksReleaseBranches