@@ -2,7 +2,6 @@ namespace GitVersion
2
2
{
3
3
using GitVersion . Configuration . Init . Wizard ;
4
4
using GitVersion . Helpers ;
5
- using System . Collections . Generic ;
6
5
using System . ComponentModel ;
7
6
using System . IO ;
8
7
using System . Linq ;
@@ -100,27 +99,25 @@ public static void ApplyOverridesTo(Config config, Config overrideConfig)
100
99
101
100
static void MigrateBranches ( Config config )
102
101
{
103
- // Map of current names and previous names
104
- var dict = new Dictionary < string , string [ ] >
105
- {
106
- { "hotfix(es)?[/-]" , new [ ] { "hotfix[/-]" } } ,
107
- { "features?[/-]" , new [ ] { "feature[/-]" , "feature(s)?[/-]" } } ,
108
- { "releases?[/-]" , new [ ] { "release[/-]" } } ,
109
- { "dev(elop)?(ment)?$" , new [ ] { "develop" } }
110
- } ;
102
+ MigrateObsoleteBranches ( config , "hotfix(es)?[/-]" , "hotfix[/-]" ) ;
103
+ MigrateObsoleteBranches ( config , "features?[/-]" , "feature[/-]" , "feature(s)?[/-]" ) ;
104
+ MigrateObsoleteBranches ( config , "releases?[/-]" , "release[/-]" ) ;
105
+ MigrateObsoleteBranches ( config , "dev(elop)?(ment)?$" , "develop" ) ;
106
+ }
111
107
112
- foreach ( var mapping in dict )
108
+ static void MigrateObsoleteBranches ( Config config , string newBranch , params string [ ] obsoleteBranches )
109
+ {
110
+ foreach ( var obsoleteBranch in obsoleteBranches )
113
111
{
114
- foreach ( var source in mapping . Value )
112
+ if ( ! config . Branches . ContainsKey ( obsoleteBranch ) )
115
113
{
116
- if ( config . Branches . ContainsKey ( source ) )
117
- {
118
- // found one, rename
119
- var bc = config . Branches [ source ] ;
120
- config . Branches . Remove ( source ) ;
121
- config . Branches [ mapping . Key ] = bc ; // re-add with new name
122
- }
114
+ continue ;
123
115
}
116
+
117
+ // found one, rename
118
+ var bc = config . Branches [ obsoleteBranch ] ;
119
+ config . Branches . Remove ( obsoleteBranch ) ;
120
+ config . Branches [ newBranch ] = bc ; // re-add with new name
124
121
}
125
122
}
126
123
0 commit comments