1
1
namespace GitVersion
2
2
{
3
+ using System . Collections . Generic ;
3
4
using System . IO ;
4
5
using System . Linq ;
5
6
using System . Text ;
@@ -20,6 +21,8 @@ public static Config Provide(string workingDirectory, IFileSystem fileSystem, bo
20
21
21
22
public static void ApplyDefaultsTo ( Config config )
22
23
{
24
+ MigrateBranches ( config ) ;
25
+
23
26
config . AssemblyVersioningScheme = config . AssemblyVersioningScheme ?? AssemblyVersioningScheme . MajorMinorPatch ;
24
27
config . TagPrefix = config . TagPrefix ?? DefaultTagPrefix ;
25
28
config . VersioningMode = config . VersioningMode ?? VersioningMode . ContinuousDelivery ;
@@ -53,6 +56,33 @@ public static void ApplyDefaultsTo(Config config)
53
56
}
54
57
}
55
58
59
+ static void MigrateBranches ( Config config )
60
+ {
61
+ // Map of current names and previous names
62
+ var dict = new Dictionary < string , string [ ] >
63
+ {
64
+ { "hotfix(es)?[/-]" , new [ ] { "hotfix[/-]" } } ,
65
+ { "features?[/-]" , new [ ] { "feature[/-]" } } ,
66
+ { "releases?[/-]" , new [ ] { "release[/-]" } } ,
67
+ { "dev(elop)?(ment)?$" , new [ ] { "develop" } }
68
+ } ;
69
+
70
+ foreach ( var mapping in dict )
71
+ {
72
+ foreach ( var source in mapping . Value )
73
+ {
74
+ if ( config . Branches . ContainsKey ( source ) )
75
+ {
76
+ // found one, rename
77
+ var bc = config . Branches [ source ] ;
78
+ config . Branches . Remove ( source ) ;
79
+ config . Branches [ mapping . Key ] = bc ; // re-add with new name
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+
56
86
static BranchConfig GetOrCreateBranchDefaults ( Config config , string branch )
57
87
{
58
88
if ( ! config . Branches . ContainsKey ( branch ) )
0 commit comments