-
Notifications
You must be signed in to change notification settings - Fork 654
Fix/release issues #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix/release issues #1342
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
94cf3ab
Allow running just tests or build from command line
3c14826
fix(merge messages): Add support for merge remote tracking style merg…
cddf40b
fix(config): When getting branch config, if we try to inherit branch …
698515e
Fixed logic around what branches to exclude from inheriting config
JakeGinnivan 0e76113
Should filter excluding branches before we calculate merge base on th…
JakeGinnivan c0ecaf0
Little bit of refactoring for LibGitExtensions
JakeGinnivan b4152e9
Because we allow remote branches to be searched, we need to lookup co…
JakeGinnivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ public class BranchConfigurationCalculator | |
/// </summary> | ||
public static BranchConfig GetBranchConfiguration(GitVersionContext context, Branch targetBranch, IList<Branch> excludedInheritBranches = null) | ||
{ | ||
var matchingBranches = context.FullConfiguration.GetConfigForBranch(targetBranch.FriendlyName); | ||
var matchingBranches = context.FullConfiguration.GetConfigForBranch(targetBranch.NameWithoutRemote()); | ||
|
||
if (matchingBranches == null) | ||
{ | ||
|
@@ -27,11 +27,20 @@ public static BranchConfig GetBranchConfiguration(GitVersionContext context, Bra | |
ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, matchingBranches, "", new List<string>()); | ||
} | ||
|
||
return matchingBranches.Increment == IncrementStrategy.Inherit ? | ||
InheritBranchConfiguration(context, targetBranch, matchingBranches, excludedInheritBranches) : | ||
matchingBranches; | ||
if (matchingBranches.Increment == IncrementStrategy.Inherit) | ||
{ | ||
matchingBranches = InheritBranchConfiguration(context, targetBranch, matchingBranches, excludedInheritBranches); | ||
if (matchingBranches.Name == FallbackConfigName && matchingBranches.Increment == IncrementStrategy.Inherit) | ||
{ | ||
// We tried, and failed to inherit, just fall back to patch | ||
matchingBranches.Increment = IncrementStrategy.Patch; | ||
} | ||
} | ||
|
||
return matchingBranches; | ||
} | ||
|
||
// TODO I think we need to take a fresh approach to this.. it's getting really complex with heaps of edge cases | ||
static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch targetBranch, BranchConfig branchConfiguration, IList<Branch> excludedInheritBranches) | ||
{ | ||
var repository = context.Repository; | ||
|
@@ -50,17 +59,17 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch | |
{ | ||
excludedInheritBranches = repository.Branches.Where(b => | ||
{ | ||
var branchConfig = config.GetConfigForBranch(b.FriendlyName); | ||
var branchConfig = config.GetConfigForBranch(b.NameWithoutRemote()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This I think is the real fix. This will now exclude local and remote branches which do not have config, or the config is Inherit. Previously we only excluded branches which had config and it was Inherit, but our infinite loops were caused by branches without config.. |
||
|
||
return branchConfig != null && branchConfig.Increment == IncrementStrategy.Inherit; | ||
return branchConfig == null || branchConfig.Increment == IncrementStrategy.Inherit; | ||
}).ToList(); | ||
} | ||
// Add new excluded branches. | ||
foreach (var excludedBranch in excludedBranches.ExcludingBranches(excludedInheritBranches)) | ||
{ | ||
excludedInheritBranches.Add(excludedBranch); | ||
} | ||
var branchesToEvaluate = repository.Branches.Except(excludedInheritBranches).ToList(); | ||
var branchesToEvaluate = repository.Branches.ExcludingBranches(excludedInheritBranches).ToList(); | ||
|
||
var branchPoint = context.RepositoryMetadataProvider | ||
.FindCommitBranchWasBranchedFrom(targetBranch, excludedInheritBranches.ToArray()); | ||
|
@@ -94,13 +103,17 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch | |
if (possibleParents.Count == 1) | ||
{ | ||
var branchConfig = GetBranchConfiguration(context, possibleParents[0], excludedInheritBranches); | ||
return new BranchConfig(branchConfiguration) | ||
// If we have resolved a fallback config we should not return that we have got config | ||
if (branchConfig.Name != FallbackConfigName) | ||
{ | ||
Increment = branchConfig.Increment, | ||
PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion, | ||
// If we are inheriting from develop then we should behave like develop | ||
TracksReleaseBranches = branchConfig.TracksReleaseBranches | ||
}; | ||
return new BranchConfig(branchConfiguration) | ||
{ | ||
Increment = branchConfig.Increment, | ||
PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion, | ||
// If we are inheriting from develop then we should behave like develop | ||
TracksReleaseBranches = branchConfig.TracksReleaseBranches | ||
}; | ||
} | ||
} | ||
|
||
// 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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't happen now because we filter the conditions which would cause this code to be executed. But still, I think it's worth keeping in just in case