public static ApplyBranchDefaults ( Config config, GitVersion.BranchConfig branchConfig, string branchRegex, string defaultTag = "useBranchName", IncrementStrategy defaultIncrementStrategy = null, bool defaultPreventIncrement = false, VersioningMode defaultVersioningMode = null, bool defaultTrackMergeTarget = false, string defaultTagNumberPattern = null, bool tracksReleaseBranches = false, bool isReleaseBranch = false, bool isMainline = false ) : void | ||
config | Config | |
branchConfig | GitVersion.BranchConfig | |
branchRegex | string | |
defaultTag | string | |
defaultIncrementStrategy | IncrementStrategy | |
defaultPreventIncrement | bool | |
defaultVersioningMode | VersioningMode | |
defaultTrackMergeTarget | bool | |
defaultTagNumberPattern | string | |
tracksReleaseBranches | bool | |
isReleaseBranch | bool | |
isMainline | bool | |
return | void |
public static KeyValuePair <string, BranchConfig> GetBranchConfiguration(Commit currentCommit, IRepository repository, bool onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList <Branch> excludedInheritBranches = null) { var matchingBranches = LookupBranchConfiguration(config, currentBranch); if (matchingBranches.Length == 0) { var branchConfig = new BranchConfig(); ConfigurationProvider.ApplyBranchDefaults(config, branchConfig); return(new KeyValuePair <string, BranchConfig>(string.Empty, branchConfig)); } if (matchingBranches.Length == 1) { var keyValuePair = matchingBranches[0]; var branchConfiguration = keyValuePair.Value; if (branchConfiguration.Increment == IncrementStrategy.Inherit) { return(InheritBranchConfiguration(onlyEvaluateTrackedBranches, repository, currentCommit, currentBranch, keyValuePair, branchConfiguration, config, excludedInheritBranches)); } return(keyValuePair); } const string format = "Multiple branch configurations match the current branch branchName of '{0}'. Matching configurations: '{1}'"; throw new Exception(string.Format(format, currentBranch.FriendlyName, string.Join(", ", matchingBranches.Select(b => b.Key)))); }
/// <summary> /// Gets the <see cref="BranchConfig"/> for the current commit. /// </summary> public static BranchConfig GetBranchConfiguration(GitVersionContext context, Branch targetBranch, IList <Branch> excludedInheritBranches = null) { var matchingBranches = LookupBranchConfiguration(context.FullConfiguration, targetBranch).ToArray(); BranchConfig branchConfiguration; if (matchingBranches.Length > 0) { branchConfiguration = matchingBranches[0]; if (matchingBranches.Length > 1) { Logger.WriteWarning(string.Format( "Multiple branch configurations match the current branch branchName of '{0}'. Using the first matching configuration, '{1}'. Matching configurations include: '{2}'", targetBranch.FriendlyName, branchConfiguration.Name, string.Join("', '", matchingBranches.Select(b => b.Name)))); } } else { Logger.WriteInfo(string.Format( "No branch configuration found for branch {0}, falling back to default configuration", targetBranch.FriendlyName)); branchConfiguration = new BranchConfig { Name = string.Empty }; ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, branchConfiguration, ""); } return(branchConfiguration.Increment == IncrementStrategy.Inherit ? InheritBranchConfiguration(context, targetBranch, branchConfiguration, excludedInheritBranches) : branchConfiguration); }
/// <summary> /// Gets the <see cref="BranchConfig"/> for the current commit. /// </summary> public static BranchConfig GetBranchConfiguration(GitVersionContext context, Branch targetBranch, IList <Branch> excludedInheritBranches = null) { var matchingBranches = context.FullConfiguration.GetConfigForBranch(targetBranch.NameWithoutRemote()); if (matchingBranches == null) { Logger.WriteInfo($"No branch configuration found for branch {targetBranch.FriendlyName}, falling back to default configuration"); matchingBranches = new BranchConfig { Name = FallbackConfigName }; ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, matchingBranches, "", new List <string>()); } if (matchingBranches.Increment == IncrementStrategy.Inherit) { matchingBranches = InheritBranchConfiguration(context, targetBranch, matchingBranches, 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); }
/// <summary> /// Gets the <see cref="BranchConfig"/> for the current commit. /// </summary> public static BranchConfig GetBranchConfiguration(GitVersionContext context, Branch targetBranch, IList <Branch> excludedInheritBranches = null) { var matchingBranches = context.FullConfiguration.GetConfigForBranch(targetBranch.FriendlyName); if (matchingBranches == null) { Logger.WriteInfo(string.Format( "No branch configuration found for branch {0}, falling back to default configuration", targetBranch.FriendlyName)); matchingBranches = new BranchConfig { Name = string.Empty }; ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, matchingBranches, "", new List <string>()); } return(matchingBranches.Increment == IncrementStrategy.Inherit ? InheritBranchConfiguration(context, targetBranch, matchingBranches, excludedInheritBranches) : matchingBranches); }