@@ -26,9 +26,43 @@ public class GitFlow
2626 public string ReleasePrefix { get ; set ; } = string . Empty ;
2727 public string HotfixPrefix { get ; set ; } = string . Empty ;
2828
29- public void Parse ( Dictionary < string , string > config , GitFlowVersion version )
29+ public void Parse ( Dictionary < string , string > config )
3030 {
31- if ( version == GitFlowVersion . Classic )
31+ // Reset to default values
32+ ProductionBranch = string . Empty ;
33+ DevelopmentBranch = string . Empty ;
34+ FeaturePrefix = string . Empty ;
35+ ReleasePrefix = string . Empty ;
36+ HotfixPrefix = string . Empty ;
37+
38+ // Try to parse `git-flow-next` style configuration first.
39+ foreach ( var kv in config )
40+ {
41+ if ( ! kv . Key . StartsWith ( "gitflow.branch." , StringComparison . Ordinal ) )
42+ continue ;
43+
44+ if ( kv . Key . EndsWith ( ".type" , StringComparison . Ordinal ) && kv . Value . Equals ( "base" , StringComparison . Ordinal ) )
45+ {
46+ var b = kv . Key . Substring ( "gitflow.branch." . Length , kv . Key . Length - "gitflow.branch." . Length - ".type" . Length ) ;
47+ if ( config . ContainsKey ( $ "gitflow.branch.{ b } .parent") )
48+ DevelopmentBranch = b ;
49+ else
50+ ProductionBranch = b ;
51+ }
52+ else if ( kv . Key . EndsWith ( ".prefix" , StringComparison . Ordinal ) )
53+ {
54+ var t = kv . Key . Substring ( "gitflow.branch." . Length , kv . Key . Length - "gitflow.branch." . Length - ".prefix" . Length ) ;
55+ if ( t . Equals ( "feature" , StringComparison . Ordinal ) )
56+ FeaturePrefix = kv . Value ;
57+ else if ( t . Equals ( "release" , StringComparison . Ordinal ) )
58+ ReleasePrefix = kv . Value ;
59+ else if ( t . Equals ( "hotfix" , StringComparison . Ordinal ) )
60+ HotfixPrefix = kv . Value ;
61+ }
62+ }
63+
64+ // Fall back to `git-flow` style configuration if `git-flow-next` style is not valid.
65+ if ( ! IsValid )
3266 {
3367 if ( config . TryGetValue ( "gitflow.branch.master" , out var masterName ) )
3468 ProductionBranch = masterName ;
@@ -41,41 +75,6 @@ public void Parse(Dictionary<string, string> config, GitFlowVersion version)
4175 if ( config . TryGetValue ( "gitflow.prefix.hotfix" , out var hotfixPrefix ) )
4276 HotfixPrefix = hotfixPrefix ;
4377 }
44- else if ( version == GitFlowVersion . Next )
45- {
46- foreach ( var kv in config )
47- {
48- if ( ! kv . Key . StartsWith ( "gitflow.branch." , StringComparison . Ordinal ) )
49- continue ;
50-
51- if ( kv . Key . EndsWith ( ".type" , StringComparison . Ordinal ) && kv . Value . Equals ( "base" , StringComparison . Ordinal ) )
52- {
53- var b = kv . Key . Substring ( "gitflow.branch." . Length , kv . Key . Length - "gitflow.branch." . Length - ".type" . Length ) ;
54- if ( config . ContainsKey ( $ "gitflow.branch.{ b } .parent") )
55- DevelopmentBranch = b ;
56- else
57- ProductionBranch = b ;
58- }
59- else if ( kv . Key . EndsWith ( ".prefix" , StringComparison . Ordinal ) )
60- {
61- var t = kv . Key . Substring ( "gitflow.branch." . Length , kv . Key . Length - "gitflow.branch." . Length - ".prefix" . Length ) ;
62- if ( t . Equals ( "feature" , StringComparison . Ordinal ) )
63- FeaturePrefix = kv . Value ;
64- else if ( t . Equals ( "release" , StringComparison . Ordinal ) )
65- ReleasePrefix = kv . Value ;
66- else if ( t . Equals ( "hotfix" , StringComparison . Ordinal ) )
67- HotfixPrefix = kv . Value ;
68- }
69- }
70- }
71- else
72- {
73- ProductionBranch = string . Empty ;
74- DevelopmentBranch = string . Empty ;
75- FeaturePrefix = string . Empty ;
76- ReleasePrefix = string . Empty ;
77- HotfixPrefix = string . Empty ;
78- }
7978 }
8079
8180 public bool IsValid
0 commit comments