/// <summary> /// Gets the <see cref="BranchConfig"/> for the current commit. /// </summary> public BranchConfig GetBranchConfiguration(IBranch targetBranch, ICommit currentCommit, Config configuration, IList <IBranch> excludedInheritBranches = null) { var matchingBranches = configuration.GetConfigForBranch(targetBranch.Name.WithoutRemote); if (matchingBranches == null) { log.Info($"No branch configuration found for branch {targetBranch}, falling back to default configuration"); matchingBranches = BranchConfig.CreateDefaultBranchConfig(FallbackConfigName) .Apply(new BranchConfig { Regex = "", VersioningMode = configuration.VersioningMode, Increment = configuration.Increment ?? IncrementStrategy.Inherit, }); } if (matchingBranches.Increment == IncrementStrategy.Inherit) { matchingBranches = InheritBranchConfiguration(targetBranch, matchingBranches, currentCommit, configuration, excludedInheritBranches); if (matchingBranches.Name.IsEquivalentTo(FallbackConfigName) && matchingBranches.Increment == IncrementStrategy.Inherit) { // We tried, and failed to inherit, just fall back to patch matchingBranches.Increment = IncrementStrategy.Patch; } } return(matchingBranches); }
/// <summary> /// Gets the <see cref="BranchConfig"/> for the current commit. /// </summary> public BranchConfig GetBranchConfiguration(Branch targetBranch, Commit currentCommit, Config configuration, IList <Branch> excludedInheritBranches = null) { var matchingBranches = configuration.GetConfigForBranch(targetBranch.NameWithoutRemote()); if (matchingBranches == null) { log.Info($"No branch configuration found for branch {targetBranch.FriendlyName}, falling back to default configuration"); matchingBranches = new BranchConfig { Name = FallbackConfigName }; configuration.ApplyBranchDefaults(matchingBranches, "", new List <string>()); } if (matchingBranches.Increment == IncrementStrategy.Inherit) { matchingBranches = InheritBranchConfiguration(targetBranch, matchingBranches, currentCommit, configuration, excludedInheritBranches); if (matchingBranches.Name == FallbackConfigName && matchingBranches.Increment == IncrementStrategy.Inherit) { // We tried, and failed to inherit, just fall back to patch matchingBranches.Increment = IncrementStrategy.Patch; } } return(matchingBranches); }
public static bool IsReleaseBranch(this Config config, string branchName) => config.GetConfigForBranch(branchName)?.IsReleaseBranch ?? false;