-
Notifications
You must be signed in to change notification settings - Fork 656
Add failing test for missing source-branch config #2348
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
asbjornu
merged 3 commits into
GitTools:master
from
michaelnoonan:michaelnoonan/missing-source-branch
Jul 8, 2020
Merged
Add failing test for missing source-branch config #2348
asbjornu
merged 3 commits into
GitTools:master
from
michaelnoonan:michaelnoonan/missing-source-branch
Jul 8, 2020
Conversation
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
We ran into a case where we added a source-branch that wasn't configured. This ultimately led to a failure way down in the RepositoryMetadataProvider. From the best I can tell this is due to having no `main` branch configuration. ``` System.Collections.Generic.KeyNotFoundException: The given key 'main' was not present in the dictionary. 13:04:34 at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 13:04:34 at GitVersion.RepositoryMetadataProvider.<>c__DisplayClass33_0.<GetMergeCommitsForBranch>b__0(String sb) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\RepositoryMetadataProvider.cs:line 475 13:04:34 at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext() 13:04:34 at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) 13:04:34 at GitVersion.RepositoryMetadataProvider.<>c__DisplayClass33_0.<GetMergeCommitsForBranch>b__1(Branch b) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\RepositoryMetadataProvider.cs:line 480 13:04:34 at System.Linq.Utilities.<>c__DisplayClass1_0`1.<CombinePredicates>b__0(TSource x) 13:04:34 at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 13:04:34 at System.Linq.Enumerable.WhereEnumerableIterator`1.ToArray() 13:04:34 at System.Linq.OrderedEnumerable`1.ToList() 13:04:34 at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) 13:04:34 at GitVersion.RepositoryMetadataProvider.GetMergeCommitsForBranch(Branch branch, Config configuration, IEnumerable`1 excludedBranches) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\RepositoryMetadataProvider.cs:line 476 13:04:34 at GitVersion.RepositoryMetadataProvider.FindCommitBranchWasBranchedFrom(Branch branch, Config configuration, Branch[] excludedBranches) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Core\RepositoryMetadataProvider.cs:line 333 13:04:34 at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(Branch targetBranch, BranchConfig branchConfiguration, Commit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Configuration\BranchConfigurationCalculator.cs:line 80 13:04:34 at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfiguration(Branch targetBranch, Commit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Configuration\BranchConfigurationCalculator.cs:line 48 ```
This was referenced Jul 7, 2020
asbjornu
requested changes
Jul 7, 2020
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.
I think this looks good, I'm just wondering how this affects standard branches such as master
and develop
.
config.Branches.ContainsKey(x) does a fuzzy-ish match. In https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/Core/RepositoryMetadataProvider.cs#L475 it does a dictionary index lookup. I've changed the test to use the same approach which is more strict.
These two tests work together to prove success and failure scenarios work as expected.
asbjornu
approved these changes
Jul 8, 2020
Thanks for your contributions, @michaelnoonan! 🙏 |
🙇♂️ Thanks for your feedback also! I think this is a nice small improvement. |
michaelnoonan
added a commit
to OctopusDeploy/ServerExtensibility
that referenced
this pull request
Jul 17, 2020
See GitTools/GitVersion#2348 for details.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
We ran into a case where we added a source-branch that wasn't configured.
This ultimately led to a failure way down in the RepositoryMetadataProvider.
From the best I can tell this is due to having no
main
branch configuration.Related Issue
#2349
Motivation and Context
This will help other people discover misconfiguration early.
How Has This Been Tested?
I'm depending on the failing test I've written.
Checklist: