Gitversion: [Bug] Cloning develop throws InvalidOperationException: Sequence contains no matching element

Created on 4 Aug 2020  路  5Comments  路  Source: GitTools/GitVersion

Describe the bug
Using develop as our default branch led to GitVersion failing locally with an incomprehensible error.

Expected Behavior

  • Version should be the same as if both master and develop have been checked out locally.
  • Not having master branch should lead to a clear warning message something like "Could not find a 'master' branch, neither locally nor remotely."

Actual Behavior

  System.InvalidOperationException : Sequence contains no matching element
  Stack Trace: 
    Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
    MainlineVersionCalculator.GetMainline(Commit baseVersionSource) line 133
    MainlineVersionCalculator.FindMainlineModeVersion(BaseVersion baseVersion) line 44
    NextVersionCalculator.FindVersion() line 59

Possible Fix

Add origin/master to regex for master.

Steps to Reproduce

See PR #2379 test GivenARemoteGitRepositoryWithCommitsThenClonedLocalDevelopShouldMatchRemoteVersion

Your Environment


  • Version Used: 5.3.7
  • Windows 10
  • Internal Azure DevOps repo
bug

Most helpful comment

Although it's not a big job normalizing the repository so a local master is available, I agree it shouldn't be necessary. For some reason, it has become required. I'm not sure why or when, but I'll agree that it can be considered a bug.

All 5 comments

Using develop as the main branch without any configuration won't work. GitVersion has intrinsic knowledge and logic built around develop that requires master to exist. If you aren't going to have a master branch, why not just call it main as supported through #2367 (unreleased, but will still be easier and safer to configure)?

Master is our main branch. We have a master branch on the server, but when a developer is working locally it only exists as origin/master.

Why should a developer be required to checkout master locally to prevent GitVersion from reporting an error on build? They will never update master directly, that always happens by accepting a pull request in ADO.

In version used, I should have also specified that we are using GitVersionTask.

Although it's not a big job normalizing the repository so a local master is available, I agree it shouldn't be necessary. For some reason, it has become required. I'm not sure why or when, but I'll agree that it can be considered a bug.

I just stumbled upon the same problem, and I agree with OP that a dedicated error message would be very helpful.

A pull request that manages to pinpoint where and when this exception occurs and write a custom error message instead would be merged instantaneously.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drewwilliams1982 picture drewwilliams1982  路  5Comments

BiribiriJaNai picture BiribiriJaNai  路  5Comments

Scharpp picture Scharpp  路  3Comments

aronsky picture aronsky  路  4Comments

pcoombe picture pcoombe  路  5Comments