System.InvalidOperationException: Sequence contains no elements exception fixed #2437
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.
System.InvalidOperationException: Sequence contains no elements exception fixed when mailineTip.Parent collection is empty
in MainlineVersionCalculator.FindMergeBaseBeforeForwardMerge method
Description
Following error occurs when running before first commit in non-mainline branch
An unexpected error occurred:
System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at GitVersion.VersionCalculation.MainlineVersionCalculator.FindMergeBaseBeforeForwardMerge(Commit baseVersionSource, Branch mainline, Commit& mainlineTip)
at GitVersion.VersionCalculation.MainlineVersionCalculator.FindMainlineModeVersion(BaseVersion baseVersion)
at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion()
at GitVersion.GitVersionTool.CalculateVersionVariables()
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions)
Steps to reproduce
Create GitVersion.yml containing only one line:
mode: Mainline
Issue following commands from GitBash:
git init
git commit -m "initial commit" --allow-empty
git commit -b feature/f1
gitversion
Related Issue
Motivation and Context
When using tool in mainline mode and running before first commit in non-mainline branch, exception occurs
How Has This Been Tested?
Debugged in local environment, comparing official release behavior and fixed version.
Checklist: