Skip to content

Conversation

@d-rakviashvili
Copy link

@d-rakviashvili d-rakviashvili commented Oct 27, 2020

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

  1. Create GitVersion.yml containing only one line:
    mode: Mainline

  2. 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:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@asbjornu
Copy link
Member

Seems like this is related to #2379, but for another use-case. Can you please add a test that fail before the provided fix is added?

@d-rakviashvili
Copy link
Author

d-rakviashvili commented Oct 27, 2020

Seems like this is related to #2379, but for another use-case. Can you please add a test that fail before the provided fix is added?

Ok, it will take some time. Have added simple steps to reproduce exception, thanks

Upd: Done
GetNextVersionOnNonMainlineBranchWithoutCommitsShouldWorkNormally

…ns no elements exception in MainlineVersionCalculator
@asbjornu asbjornu added this to the 5.5.1 milestone Oct 27, 2020
@asbjornu asbjornu merged commit 40bdc83 into GitTools:master Oct 27, 2020
@asbjornu
Copy link
Member

This is most excellent! Thank you for your contributions, @d-rakviashvili! 🙏

@arturcic arturcic added the bug label Oct 29, 2020
@github-actions
Copy link

🎉 This issue has been resolved in version 5.5.1 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants