@@ -3,7 +3,7 @@ namespace GitVersion.Configuration.Init.SetConfig
3
3
using System ;
4
4
using System . Collections . Generic ;
5
5
using System . Linq ;
6
- using GitVersion . Configuration . Init . Wizard ;
6
+ using Wizard ;
7
7
using GitVersion . Helpers ;
8
8
9
9
public class ConfigureBranches : ConfigInitWizardStep
@@ -26,7 +26,13 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
26
26
try
27
27
{
28
28
var foundBranch = OrderedBranches ( config ) . ElementAt ( parsed - 1 ) ;
29
- steps . Enqueue ( new ConfigureBranch ( foundBranch . Key , foundBranch . Value , Console , FileSystem ) ) ;
29
+ var branchConfig = foundBranch . Value ;
30
+ if ( branchConfig == null )
31
+ {
32
+ branchConfig = new BranchConfig ( ) ;
33
+ config . Branches . Add ( foundBranch . Key , branchConfig ) ;
34
+ }
35
+ steps . Enqueue ( new ConfigureBranch ( foundBranch . Key , branchConfig , Console , FileSystem ) ) ;
30
36
return StepResult . Ok ( ) ;
31
37
}
32
38
catch ( ArgumentOutOfRangeException )
@@ -46,7 +52,13 @@ protected override string GetPrompt(Config config, string workingDirectory)
46
52
47
53
static IOrderedEnumerable < KeyValuePair < string , BranchConfig > > OrderedBranches ( Config config )
48
54
{
49
- return config . Branches . OrderBy ( b => b . Key ) ;
55
+ var defaultConfig = new Config ( ) ;
56
+ ConfigurationProvider . ApplyDefaultsTo ( defaultConfig ) ;
57
+ var defaultConfigurationBranches = defaultConfig . Branches
58
+ . Where ( k => ! config . Branches . ContainsKey ( k . Key ) )
59
+ // Return an empty branch config
60
+ . Select ( v => new KeyValuePair < string , BranchConfig > ( v . Key , null ) ) ;
61
+ return config . Branches . Union ( defaultConfigurationBranches ) . OrderBy ( b => b . Key ) ;
50
62
}
51
63
52
64
protected override string DefaultResult
0 commit comments