@@ -15,7 +15,7 @@ public class BranchConfigurationCalculator
1515 /// </summary>
1616 public static BranchConfig GetBranchConfiguration ( GitVersionContext context , Branch targetBranch , IList < Branch > excludedInheritBranches = null )
1717 {
18- var matchingBranches = context . FullConfiguration . GetConfigForBranch ( targetBranch . FriendlyName ) ;
18+ var matchingBranches = context . FullConfiguration . GetConfigForBranch ( targetBranch . NameWithoutRemote ( ) ) ;
1919
2020 if ( matchingBranches == null )
2121 {
@@ -27,11 +27,20 @@ public static BranchConfig GetBranchConfiguration(GitVersionContext context, Bra
2727 ConfigurationProvider . ApplyBranchDefaults ( context . FullConfiguration , matchingBranches , "" , new List < string > ( ) ) ;
2828 }
2929
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 ;
3341 }
3442
43+ // TODO I think we need to take a fresh approach to this.. it's getting really complex with heaps of edge cases
3544 static BranchConfig InheritBranchConfiguration ( GitVersionContext context , Branch targetBranch , BranchConfig branchConfiguration , IList < Branch > excludedInheritBranches )
3645 {
3746 var repository = context . Repository ;
@@ -50,17 +59,17 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch
5059 {
5160 excludedInheritBranches = repository . Branches . Where ( b =>
5261 {
53- var branchConfig = config . GetConfigForBranch ( b . FriendlyName ) ;
62+ var branchConfig = config . GetConfigForBranch ( b . NameWithoutRemote ( ) ) ;
5463
55- return branchConfig != null && branchConfig . Increment == IncrementStrategy . Inherit ;
64+ return branchConfig == null || branchConfig . Increment == IncrementStrategy . Inherit ;
5665 } ) . ToList ( ) ;
5766 }
5867 // Add new excluded branches.
5968 foreach ( var excludedBranch in excludedBranches . ExcludingBranches ( excludedInheritBranches ) )
6069 {
6170 excludedInheritBranches . Add ( excludedBranch ) ;
6271 }
63- var branchesToEvaluate = repository . Branches . Except ( excludedInheritBranches ) . ToList ( ) ;
72+ var branchesToEvaluate = repository . Branches . ExcludingBranches ( excludedInheritBranches ) . ToList ( ) ;
6473
6574 var branchPoint = context . RepositoryMetadataProvider
6675 . FindCommitBranchWasBranchedFrom ( targetBranch , excludedInheritBranches . ToArray ( ) ) ;
@@ -94,13 +103,17 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch
94103 if ( possibleParents . Count == 1 )
95104 {
96105 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 )
98108 {
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+ }
104117 }
105118
106119 // 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