|
| 1 | +using GitVersion.VersionCalculation; |
| 2 | + |
| 3 | +namespace GitVersion.Configuration; |
| 4 | + |
| 5 | +internal sealed class TrunkBasedConfigurationBuilder : ConfigurationBuilderBase<TrunkBasedConfigurationBuilder> |
| 6 | +{ |
| 7 | + public static TrunkBasedConfigurationBuilder New => new(); |
| 8 | + |
| 9 | + private TrunkBasedConfigurationBuilder() |
| 10 | + { |
| 11 | + WithConfiguration(new GitVersionConfiguration() |
| 12 | + { |
| 13 | + AssemblyFileVersioningScheme = ConfigurationConstants.DefaultAssemblyFileVersioningScheme, |
| 14 | + AssemblyVersioningScheme = ConfigurationConstants.DefaultAssemblyVersioningScheme, |
| 15 | + CommitDateFormat = ConfigurationConstants.DefaultCommitDateFormat, |
| 16 | + MajorVersionBumpMessage = IncrementStrategyFinder.DefaultMajorPattern, |
| 17 | + MinorVersionBumpMessage = IncrementStrategyFinder.DefaultMinorPattern, |
| 18 | + NoBumpMessage = IncrementStrategyFinder.DefaultNoBumpPattern, |
| 19 | + PatchVersionBumpMessage = IncrementStrategyFinder.DefaultPatchPattern, |
| 20 | + SemanticVersionFormat = ConfigurationConstants.DefaultSemanticVersionFormat, |
| 21 | + VersionStrategies = [ |
| 22 | + VersionStrategies.ConfiguredNextVersion, |
| 23 | + VersionStrategies.TrunkBased |
| 24 | + ], |
| 25 | + TagPrefix = ConfigurationConstants.DefaultTagPrefix, |
| 26 | + VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern, |
| 27 | + TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight, |
| 28 | + UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber, |
| 29 | + DeploymentMode = DeploymentMode.ManualDeployment, |
| 30 | + RegularExpression = string.Empty, |
| 31 | + Label = ConfigurationConstants.BranchNamePlaceholder, |
| 32 | + Increment = IncrementStrategy.Inherit, |
| 33 | + CommitMessageIncrementing = CommitMessageIncrementMode.Enabled, |
| 34 | + PreventIncrement = new PreventIncrementConfiguration() |
| 35 | + { |
| 36 | + OfMergedBranch = false, |
| 37 | + WhenBranchMerged = false, |
| 38 | + WhenCurrentCommitTagged = true |
| 39 | + }, |
| 40 | + TrackMergeTarget = false, |
| 41 | + TrackMergeMessage = true, |
| 42 | + TracksReleaseBranches = false, |
| 43 | + IsReleaseBranch = false, |
| 44 | + IsMainBranch = false |
| 45 | + }); |
| 46 | + |
| 47 | + WithBranch(MainBranch.Name).WithConfiguration(new BranchConfiguration() |
| 48 | + { |
| 49 | + Increment = IncrementStrategy.Patch, |
| 50 | + RegularExpression = MainBranch.RegexPattern, |
| 51 | + DeploymentMode = DeploymentMode.ContinuousDeployment, |
| 52 | + SourceBranches = [], |
| 53 | + Label = string.Empty, |
| 54 | + PreventIncrement = new PreventIncrementConfiguration() |
| 55 | + { |
| 56 | + OfMergedBranch = true |
| 57 | + }, |
| 58 | + TrackMergeTarget = false, |
| 59 | + TracksReleaseBranches = false, |
| 60 | + IsMainBranch = true, |
| 61 | + IsReleaseBranch = false, |
| 62 | + PreReleaseWeight = 55000 |
| 63 | + }); |
| 64 | + |
| 65 | + WithBranch(FeatureBranch.Name).WithConfiguration(new BranchConfiguration() |
| 66 | + { |
| 67 | + Increment = IncrementStrategy.Minor, |
| 68 | + RegularExpression = FeatureBranch.RegexPattern, |
| 69 | + SourceBranches = |
| 70 | + [ |
| 71 | + this.MainBranch.Name |
| 72 | + ], |
| 73 | + PreventIncrement = new PreventIncrementConfiguration() |
| 74 | + { |
| 75 | + WhenCurrentCommitTagged = false |
| 76 | + }, |
| 77 | + PreReleaseWeight = 30000 |
| 78 | + }); |
| 79 | + |
| 80 | + WithBranch(HotfixBranch.Name).WithConfiguration(new BranchConfiguration() |
| 81 | + { |
| 82 | + Increment = IncrementStrategy.Patch, |
| 83 | + RegularExpression = HotfixBranch.RegexPattern, |
| 84 | + SourceBranches = |
| 85 | + [ |
| 86 | + this.MainBranch.Name |
| 87 | + ], |
| 88 | + PreventIncrement = new PreventIncrementConfiguration() |
| 89 | + { |
| 90 | + WhenCurrentCommitTagged = false |
| 91 | + }, |
| 92 | + PreReleaseWeight = 30000 |
| 93 | + }); |
| 94 | + |
| 95 | + WithBranch(PullRequestBranch.Name).WithConfiguration(new BranchConfiguration |
| 96 | + { |
| 97 | + Increment = IncrementStrategy.Inherit, |
| 98 | + RegularExpression = PullRequestBranch.RegexPattern, |
| 99 | + DeploymentMode = DeploymentMode.ManualDeployment, |
| 100 | + SourceBranches = |
| 101 | + [ |
| 102 | + this.MainBranch.Name |
| 103 | + ], |
| 104 | + Label = "PullRequest", |
| 105 | + LabelNumberPattern = ConfigurationConstants.DefaultLabelNumberPattern, |
| 106 | + PreReleaseWeight = 30000 |
| 107 | + }); |
| 108 | + |
| 109 | + WithBranch(UnknownBranch.Name).WithConfiguration(new BranchConfiguration |
| 110 | + { |
| 111 | + RegularExpression = UnknownBranch.RegexPattern, |
| 112 | + DeploymentMode = DeploymentMode.ManualDeployment, |
| 113 | + Increment = IncrementStrategy.Inherit, |
| 114 | + SourceBranches = |
| 115 | + [ |
| 116 | + this.MainBranch.Name, |
| 117 | + this.FeatureBranch.Name, |
| 118 | + this.PullRequestBranch.Name |
| 119 | + ] |
| 120 | + }); |
| 121 | + } |
| 122 | +} |
0 commit comments