@@ -30,6 +30,8 @@ public class ConfigurationProvider
30
30
public const string SupportBranchKey = "support" ;
31
31
public const string DevelopBranchKey = "develop" ;
32
32
33
+ private const IncrementStrategy DefaultIncrementStrategy = IncrementStrategy . Inherit ;
34
+
33
35
public static Config Provide ( GitPreparer gitPreparer , IFileSystem fileSystem , bool applyDefaults = true , Config overrideConfig = null )
34
36
{
35
37
var workingDirectory = gitPreparer . WorkingDirectory ;
@@ -99,33 +101,53 @@ public static void ApplyDefaultsTo(Config config)
99
101
100
102
var configBranches = config . Branches . ToList ( ) ;
101
103
102
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , MasterBranchKey ) ,
104
+ ApplyBranchDefaults ( config ,
105
+ GetOrCreateBranchDefaults ( config , MasterBranchKey ) ,
103
106
MasterBranchRegex ,
104
107
defaultTag : string . Empty ,
105
108
defaultPreventIncrement : true ,
109
+ defaultIncrementStrategy : IncrementStrategy . Patch ,
106
110
isMainline : true ) ;
107
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , ReleaseBranchKey ) , ReleaseBranchRegex , defaultTag : "beta" , defaultPreventIncrement : true , isReleaseBranch : true ) ;
108
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , FeatureBranchKey ) , FeatureBranchRegex , defaultIncrementStrategy : IncrementStrategy . Inherit ) ;
109
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , PullRequestBranchKey ) , PullRequestRegex ,
111
+ ApplyBranchDefaults ( config ,
112
+ GetOrCreateBranchDefaults ( config , ReleaseBranchKey ) ,
113
+ ReleaseBranchRegex ,
114
+ defaultTag : "beta" ,
115
+ defaultPreventIncrement : true ,
116
+ defaultIncrementStrategy : IncrementStrategy . Patch ,
117
+ isReleaseBranch : true ) ;
118
+ ApplyBranchDefaults ( config ,
119
+ GetOrCreateBranchDefaults ( config , FeatureBranchKey ) ,
120
+ FeatureBranchRegex ,
121
+ defaultIncrementStrategy : IncrementStrategy . Inherit ) ;
122
+ ApplyBranchDefaults ( config ,
123
+ GetOrCreateBranchDefaults ( config , PullRequestBranchKey ) ,
124
+ PullRequestRegex ,
110
125
defaultTag : "PullRequest" ,
111
126
defaultTagNumberPattern : @"[/-](?<number>\d+)[-/]" ,
112
127
defaultIncrementStrategy : IncrementStrategy . Inherit ) ;
113
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , HotfixBranchKey ) , HotfixBranchRegex , defaultTag : "beta" ) ;
114
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , SupportBranchKey ) ,
128
+ ApplyBranchDefaults ( config ,
129
+ GetOrCreateBranchDefaults ( config , HotfixBranchKey ) ,
130
+ HotfixBranchRegex ,
131
+ defaultTag : "beta" ,
132
+ defaultIncrementStrategy : IncrementStrategy . Patch ) ;
133
+ ApplyBranchDefaults ( config ,
134
+ GetOrCreateBranchDefaults ( config , SupportBranchKey ) ,
115
135
SupportBranchRegex ,
116
136
defaultTag : string . Empty ,
117
137
defaultPreventIncrement : true ,
138
+ defaultIncrementStrategy : IncrementStrategy . Patch ,
118
139
isMainline : true ) ;
119
- ApplyBranchDefaults ( config , GetOrCreateBranchDefaults ( config , DevelopBranchKey ) ,
140
+ ApplyBranchDefaults ( config ,
141
+ GetOrCreateBranchDefaults ( config , DevelopBranchKey ) ,
120
142
DevelopBranchRegex ,
121
143
defaultTag : "alpha" ,
122
144
defaultIncrementStrategy : IncrementStrategy . Minor ,
123
145
defaultVersioningMode : VersioningMode . ContinuousDeployment ,
124
146
defaultTrackMergeTarget : true ,
125
147
tracksReleaseBranches : true ) ;
126
148
127
- // Any user defined branches should have other values defaulted after known branches filled in
128
- // This allows users to override one value of
149
+ // Any user defined branches should have other values defaulted after known branches filled in.
150
+ // This allows users to override any of the value.
129
151
foreach ( var branchConfig in configBranches )
130
152
{
131
153
var regex = branchConfig . Value . Regex ;
@@ -159,7 +181,7 @@ public static void ApplyBranchDefaults(Config config,
159
181
BranchConfig branchConfig ,
160
182
string branchRegex ,
161
183
string defaultTag = "useBranchName" ,
162
- IncrementStrategy defaultIncrementStrategy = IncrementStrategy . Patch ,
184
+ IncrementStrategy ? defaultIncrementStrategy = null , // Looked up from main config
163
185
bool defaultPreventIncrement = false ,
164
186
VersioningMode ? defaultVersioningMode = null , // Looked up from main config
165
187
bool defaultTrackMergeTarget = false ,
@@ -171,7 +193,7 @@ public static void ApplyBranchDefaults(Config config,
171
193
branchConfig . Regex = string . IsNullOrEmpty ( branchConfig . Regex ) ? branchRegex : branchConfig . Regex ;
172
194
branchConfig . Tag = branchConfig . Tag ?? defaultTag ;
173
195
branchConfig . TagNumberPattern = branchConfig . TagNumberPattern ?? defaultTagNumberPattern ;
174
- branchConfig . Increment = branchConfig . Increment ?? defaultIncrementStrategy ;
196
+ branchConfig . Increment = branchConfig . Increment ?? defaultIncrementStrategy ?? config . Increment ?? DefaultIncrementStrategy ;
175
197
branchConfig . PreventIncrementOfMergedBranchVersion = branchConfig . PreventIncrementOfMergedBranchVersion ?? defaultPreventIncrement ;
176
198
branchConfig . TrackMergeTarget = branchConfig . TrackMergeTarget ?? defaultTrackMergeTarget ;
177
199
branchConfig . VersioningMode = branchConfig . VersioningMode ?? defaultVersioningMode ?? config . VersioningMode ;
0 commit comments