@@ -27,11 +27,20 @@ public static BranchConfig GetBranchConfiguration(GitVersionContext context, Bra
27
27
ConfigurationProvider . ApplyBranchDefaults ( context . FullConfiguration , matchingBranches , "" , new List < string > ( ) ) ;
28
28
}
29
29
30
- return matchingBranches . Increment == IncrementStrategy . Inherit ?
31
- InheritBranchConfiguration ( context , targetBranch , matchingBranches , excludedInheritBranches ) :
32
- matchingBranches ;
30
+ if ( matchingBranches . Increment == IncrementStrategy . Inherit )
31
+ {
32
+ matchingBranches = InheritBranchConfiguration ( context , targetBranch , matchingBranches , excludedInheritBranches ) ;
33
+ if ( matchingBranches . Name == FallbackConfigName && matchingBranches . Increment == IncrementStrategy . Inherit )
34
+ {
35
+ // We tried, and failed to inherit, just fall back to patch
36
+ matchingBranches . Increment = IncrementStrategy . Patch ;
37
+ }
38
+ }
39
+
40
+ return matchingBranches ;
33
41
}
34
42
43
+ // TODO I think we need to take a fresh approach to this.. it's getting really complex with heaps of edge cases
35
44
static BranchConfig InheritBranchConfiguration ( GitVersionContext context , Branch targetBranch , BranchConfig branchConfiguration , IList < Branch > excludedInheritBranches )
36
45
{
37
46
var repository = context . Repository ;
@@ -94,13 +103,36 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch
94
103
if ( possibleParents . Count == 1 )
95
104
{
96
105
var branchConfig = GetBranchConfiguration ( context , possibleParents [ 0 ] , excludedInheritBranches ) ;
97
- return new BranchConfig ( branchConfiguration )
106
+ // If we have resolved a fallback config we should not return that we have got config
107
+ if ( branchConfig . Name != FallbackConfigName )
98
108
{
99
- Increment = branchConfig . Increment ,
100
- PreventIncrementOfMergedBranchVersion = branchConfig . PreventIncrementOfMergedBranchVersion ,
101
- // If we are inheriting from develop then we should behave like develop
102
- TracksReleaseBranches = branchConfig . TracksReleaseBranches
103
- } ;
109
+ return new BranchConfig ( branchConfiguration )
110
+ {
111
+ Increment = branchConfig . Increment ,
112
+ PreventIncrementOfMergedBranchVersion = branchConfig . PreventIncrementOfMergedBranchVersion ,
113
+ // If we are inheriting from develop then we should behave like develop
114
+ TracksReleaseBranches = branchConfig . TracksReleaseBranches
115
+ } ;
116
+ }
117
+ }
118
+
119
+ if ( possibleParents . Count > 1 )
120
+ {
121
+ // Lets try and get the branch config for each possible parent, the first may not have config
122
+ foreach ( var possibleParent in possibleParents )
123
+ {
124
+ var branchConfig = GetBranchConfiguration ( context , possibleParent , excludedInheritBranches ) ;
125
+ if ( branchConfig . Name != FallbackConfigName )
126
+ {
127
+ return new BranchConfig ( branchConfiguration )
128
+ {
129
+ Increment = branchConfig . Increment ,
130
+ PreventIncrementOfMergedBranchVersion = branchConfig . PreventIncrementOfMergedBranchVersion ,
131
+ // If we are inheriting from develop then we should behave like develop
132
+ TracksReleaseBranches = branchConfig . TracksReleaseBranches
133
+ } ;
134
+ }
135
+ }
104
136
}
105
137
106
138
// If we fail to inherit it is probably because the branch has been merged and we can't do much. So we will fall back to develop's config
0 commit comments