GitVersion: Sequence Contains No Matching Elements

I get the following message when running GitVersion against my repo, the repo is currently git, however it has been converted from cvs to svn to hg before git.

INFO [05/04/19 8:49:53:53] Working directory: C:\github\axiom3d\axiom
INFO [05/04/19 8:49:53:54] IsDynamicGitRepository: False
INFO [05/04/19 8:49:53:56] Returning Project Root from DotGitDirectory: C:\github\axiom3d\axiom\.git - C:\github\axiom3d\axiom
INFO [05/04/19 8:49:53:56] Running on Windows.
INFO [05/04/19 8:49:53:57] IsDynamicGitRepository: False
INFO [05/04/19 8:49:53:57] Returning Project Root from DotGitDirectory: C:\github\axiom3d\axiom\.git - C:\github\axiom3d\axiom
INFO [05/04/19 8:49:53:57] Project root is: C:\github\axiom3d\axiom
INFO [05/04/19 8:49:53:57] DotGit directory is: C:\github\axiom3d\axiom\.git
INFO [05/04/19 8:49:53:58] IsDynamicGitRepository: False
INFO [05/04/19 8:49:53:58] Returning Project Root from DotGitDirectory: C:\github\axiom3d\axiom\.git - C:\github\axiom3d\axiom
INFO [05/04/19 8:49:53:61] Begin: Loading version variables from disk cache
  INFO [05/04/19 8:49:53:61] Cache file C:\github\axiom3d\axiom\.git\gitversion_cache\A4BFA58BA7D9A0DD82E47CA1096478A4938DEE97.yml not found.
INFO [05/04/19 8:49:53:62] End: Loading version variables from disk cache (Took: 1.96ms)
INFO [05/04/19 8:49:53:62] IsDynamicGitRepository: False
INFO [05/04/19 8:49:53:62] Returning Project Root from DotGitDirectory: C:\github\axiom3d\axiom\.git - C:\github\axiom3d\axiom
INFO [05/04/19 8:49:53:73] Using latest commit on specified branch
INFO [05/04/19 8:49:53:74] No branch configuration found for branch v0.8.0.0, falling back to default configuration
INFO [05/04/19 8:49:53:75] Begin: Attempting to inherit branch configuration from parent branch
  INFO [05/04/19 8:49:53:77] Begin: Finding branch source of 'v0.8.0.0'
    INFO [05/04/19 8:49:53:80] Begin: Finding merge base between 'v0.8.0.0' and 'develop'.
      INFO [05/04/19 8:49:53:83] Found merge base of 4bae1c05591012d220d58c03531f5fdf32d9daf5
      INFO [05/04/19 8:49:53:85] Merge base of v0.8.0.0' and 'develop is 4bae1c05591012d220d58c03531f5fdf32d9daf5
    INFO [05/04/19 8:49:53:85] End: Finding merge base between 'v0.8.0.0' and 'develop'. (Took: 47.00ms)
    INFO [05/04/19 8:49:53:85] Begin: Finding merge base between 'v0.8.0.0' and 'master'.
      INFO [05/04/19 8:49:53:86] Merge base of v0.8.0.0' and 'master is
    INFO [05/04/19 8:49:53:86] End: Finding merge base between 'v0.8.0.0' and 'master'. (Took: 14.00ms)
    INFO [05/04/19 8:49:53:86] Begin: Finding merge base between 'v0.8.0.0' and 'origin/develop'.
      INFO [05/04/19 8:49:53:88] Found merge base of 4bae1c05591012d220d58c03531f5fdf32d9daf5
      INFO [05/04/19 8:49:53:91] Merge base of v0.8.0.0' and 'origin/develop is 4bae1c05591012d220d58c03531f5fdf32d9daf5
    INFO [05/04/19 8:49:53:91] End: Finding merge base between 'v0.8.0.0' and 'origin/develop'. (Took: 48.00ms)
    INFO [05/04/19 8:49:53:91] Begin: Finding merge base between 'v0.8.0.0' and 'origin/master'.
      INFO [05/04/19 8:49:53:91] Merge base of v0.8.0.0' and 'origin/master is
    INFO [05/04/19 8:49:53:91] End: Finding merge base between 'v0.8.0.0' and 'origin/master'. (Took: 2.00ms)
    INFO [05/04/19 8:49:53:93] Multiple source branches have been found, picking the first one (develop).
This may result in incorrect commit counting.
Options were:
develop, origin/develop
  INFO [05/04/19 8:49:53:93] End: Finding branch source of 'v0.8.0.0' (Took: 157.00ms)
  INFO [05/04/19 8:49:53:93] Begin: Getting branches containing the commit '4bae1c05591012d220d58c03531f5fdf32d9daf5'.
    INFO [05/04/19 8:49:53:93] Trying to find direct branches.
    INFO [05/04/19 8:49:53:93] No direct branches found, searching through tracked branches.
    INFO [05/04/19 8:49:53:94] Searching for commits reachable from 'origin/develop'.
    INFO [05/04/19 8:49:53:97] The branch 'origin/develop' has a matching commit.
    INFO [05/04/19 8:49:53:97] Searching for commits reachable from 'origin/master'.
    INFO [05/04/19 8:49:53:97] The branch 'origin/master' has no matching commits.
  INFO [05/04/19 8:49:53:97] End: Getting branches containing the commit '4bae1c05591012d220d58c03531f5fdf32d9daf5'. (Took: 39.01ms)
  INFO [05/04/19 8:49:53:97] Found possible parent branches: origin/develop
INFO [05/04/19 8:49:53:97] End: Attempting to inherit branch configuration from parent branch (Took: 227.05ms)
INFO [05/04/19 8:49:53:99] Running against branch: v0.8.0.0 (d916c5fd44d1c1f96b6a3543c70416d2a769d3d7)
INFO [05/04/19 8:49:54:00] Begin: Calculating base versions
  INFO [05/04/19 8:49:54:03] Fallback base version: 0.1.0 with commit count source af4e68e39330a1b65f42035668cff977f6512592 (Incremented: None)
  INFO [05/04/19 8:49:54:10] NextVersion in GitVersion configuration file: 0.9.0 with commit count source External Source (Incremented: None)
  INFO [05/04/19 8:49:54:15] Git tag 'v0.8.3376.12322': 0.8.3376+12322 with commit count source a607690d514416d025ff0b8474ffaeedfb0d4984 (Incremented: 0.9.0)
  INFO [05/04/19 8:49:54:17] Git tag 'v0.8.3101.12095': 0.8.3101+12095 with commit count source 88819d35c5ce02eb23b7082a4bfd0bbccb0226ee (Incremented: 0.9.0)
  INFO [05/04/19 8:49:54:23] Begin: Finding branch source of 'v0.8.0.0'
    INFO [05/04/19 8:49:54:23] Multiple source branches have been found, picking the first one (develop).
This may result in incorrect commit counting.
Options were:
develop, origin/develop
  INFO [05/04/19 8:49:54:23] End: Finding branch source of 'v0.8.0.0' (Took: 0.00ms)
  INFO [05/04/19 8:49:54:23] Version in branch name: 0.8.0+0 with commit count source 4bae1c05591012d220d58c03531f5fdf32d9daf5 (Incremented: None)
  INFO [05/04/19 8:49:54:26] Found multiple base versions which will produce the same SemVer (0.9.0), taking oldest source for commit counting (Git tag 'v0.8.3101.12095')
  INFO [05/04/19 8:49:54:27] Base version used: Git tag 'v0.8.3101.12095': 0.8.3101+12095 with commit count source 88819d35c5ce02eb23b7082a4bfd0bbccb0226ee (Incremented: 0.9.0)
INFO [05/04/19 8:49:54:27] End: Calculating base versions (Took: 272.94ms)
INFO [05/04/19 8:49:54:28] Begin: Using mainline development mode to calculate current version
  INFO [05/04/19 8:49:54:31] Multiple possible mainlines pointing at the same commit, dropping origin/master
  INFO [05/04/19 8:49:54:31] Found possible mainline branches:
INFO [05/04/19 8:49:54:35] End: Using mainline development mode to calculate current version (Took: 69.97ms)
ERROR [05/04/19 8:49:54:36] An unexpected error occurred:
System.InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
  at GitVersion.VersionCalculation.MainlineVersionCalculator.GetMainlineTip(GitVersionContext context)
  at GitVersion.VersionCalculation.MainlineVersionCalculator.FindMainlineModeVersion(BaseVersion baseVersion, GitVersionContext context)
  at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion(GitVersionContext context)
  at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context)
  at GitVersion.ExecuteCore.<>c__DisplayClass6_0.<ExecuteInternal>b__0(IRepository repo)
  at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
  at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
  at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
  at GitVersion.Program.VerifyArgumentsAndRun()
INFO [05/04/19 8:49:54:36]
INFO [05/04/19 8:49:54:36] Attempting to show the current git graph (please include in issue):
INFO [05/04/19 8:49:54:36] Showing max of 100 commits
INFO [05/04/19 8:49:54:65] *   1d261cd90 7 days ago  (origin/develop, develop)
|\
| * d44cf7867 7 days ago  (origin/UpgradeToLatest, UpgradeToLatest)
| * 6d38b3503 7 days ago
| * e64d9906b 3 weeks ago
| * e94a5bb17 3 weeks ago
| * 821980450 4 weeks ago
| * c3c3a67b9 4 weeks ago
| * b2ffad98a 4 weeks ago
| * 6bdd21902 4 weeks ago
| * 80750bc34 4 weeks ago
| * aaa27e753 4 weeks ago
| * 37a75f42a 4 weeks ago
| * 2aeb37794 4 weeks ago
| * 4e85c1a40 4 weeks ago
| * 522fd8e3f 4 weeks ago
| * 7fb211136 7 weeks ago
| * 4b245fa5d 7 weeks ago
| * 2c77788bc 7 weeks ago
| * dc131d87d 7 weeks ago
| * 36872f495 7 weeks ago
| * b22b00a19 7 weeks ago
| * 9e69f409f 7 weeks ago
| * 2fbcce393 7 weeks ago
| * 127c75194 7 weeks ago
| * 39c78e35a 7 weeks ago
| * 163b0636a 7 weeks ago
| * 58711c1c9 7 weeks ago
| * e06277197 7 weeks ago
| * f520bc97d 7 weeks ago
| * 221c6b574 7 weeks ago
| * 2834dde16 7 weeks ago
| * 0ae0aff6f 7 weeks ago
| * b85842a4f 7 weeks ago
| * a634b45e0 7 weeks ago
| * 9b548a08d 7 weeks ago
| * ace554d37 8 weeks ago
| * 538e11597 9 weeks ago
| * bef32d1e1 9 weeks ago
| * 4315dc7fb 9 weeks ago
| * b30c6c8e5 9 weeks ago
| | *   19bbcc121 5 months ago  (refs/stash)
| | |\
| | | * 0d9227eca 5 months ago
| | |/
| | * 145744d00 5 months ago  (DotNetStandard2)
| |/
| * 2b4d8ee17 6 months ago
|/
*   588567ebe 2 years, 10 months ago
|\
| *   bf6f0c9a0 2 years, 11 months ago
| |\
| * | d49a6b61f 2 years, 11 months ago
| * | 0500ce07a 2 years, 11 months ago
| * | 6d735658f 2 years, 11 months ago
| * | 0b656d94f 2 years, 11 months ago
| * | de22e1170 2 years, 11 months ago
| * | 204f077a9 2 years, 11 months ago
| * | 371bfb472 2 years, 11 months ago
| * | 937d2cb9b 2 years, 11 months ago
| * | fa1e82570 2 years, 11 months ago
| * | 8d5e30f6e 2 years, 11 months ago
| * | 0681132fd 2 years, 11 months ago
| * | 69493e50e 2 years, 11 months ago
| * | 3b2c09e7a 2 years, 11 months ago
| * | 11cb786c7 2 years, 11 months ago
| * | 14e5fca8e 2 years, 11 months ago
| * | 30ca26640 2 years, 11 months ago
| * | 48e58b07e 2 years, 11 months ago
| * | 4202f3db4 2 years, 11 months ago
| * | 08efe4b06 5 years ago
| * | a8dea04a2 5 years ago
| * | 1281c4030 5 years ago
|  /
* | cfe3d27c1 2 years, 11 months ago  (origin/master, origin/HEAD, master)
* | 1b26c63ca 2 years, 11 months ago
* |   76994381e 2 years, 11 months ago
|\ \
| * | 2925c491e 2 years, 11 months ago
| |\ \
| | * | 64661e024 2 years, 11 months ago
| | * | a4f874828 2 years, 11 months ago
| | * |   53208f08e 2 years, 11 months ago
| | |\ \
| | | * | fdee05a9d 2 years, 11 months ago
| | | * | 246ac9a96 2 years, 11 months ago
| | | * | 4ec6fee10 2 years, 11 months ago
| | | * | dad09ee82 2 years, 11 months ago
| | | * | f6e8f78b1 2 years, 11 months ago
| | | * | c911353fd 2 years, 11 months ago
| | |  /
| | * | 562b937a1 2 years, 11 months ago
| | * | 9d4340b6b 2 years, 11 months ago
| |  /
| * | 36938f9de 2 years, 11 months ago
| * | 32b6d2774 2 years, 11 months ago
|  /
* | 55a90b221 2 years, 11 months ago
* | 0ee380505 2 years, 11 months ago  (origin/opentk)
/
| * ea5d5230d 6 months ago  (origin/mono.simd)
| * 5eaeb50aa 6 years ago
| * b75e9eeba 10 years ago
| * f8b4fd18d 10 years ago
| * 2c1c0704d 10 years ago
| * bc46eb35b 10 years ago
| * 6171eb2f5 10 years ago
| * 2a90cb8fa 10 years ago
| | * 1339b33c3 5 years ago  (origin/WinRT, WinRT)
| | * 85fc2dc26 5 years ago
| | * 569afda98 6 years ago

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I had the same issue when using mode Mainline on Jenkins. What I did that solved my issue was adding this regex to master:

master:
    regex: (^master$|^origin\/master$)
    tag: ''
    increment: minor

GitVersion will now look at origin/master also, instead of just looking at master.

Thanks for providing a public repository to reproduce this error, @tmm360. I am, however, unable to reproduce the error. I’ve cloned https://github.com/tmm360/gitversion-issue1671 and have checked out HEAD (tmm360/gitversion-issue1671@9bcd6d4) of main. Running GitVersion there succeeds. What do I need to do to make it fail?

I’ve tried again, and now it works also for me. What is not fixed to a specific version is the container mcr.microsoft.com/dotnet/sdk:5.0, that could has been updated. After all, I saw that to use docker was a requirement for the issue to manifest (v0.1.4). Maybe issue was related to a previous version of that container, and now it has been resolved.

I had this issue as well. For me, the issue was that the build server (TFS) did not have master or the branch checked out, rather it was operating in detached head state. Normally, GitVersion is smart enough to detect this condition, but it is powerless to do so in a Docker container.

I was able to work around the issue using a bash script like this (please note that the $(...) looking variables are TFS specific variables):

branchName="$(Build.SourceBranchName)"

if [ -n "$(System.PullRequest.PullRequestId)" ]
then
  branchName="PullRequest$(System.PullRequest.PullRequestId)"
fi

# Checkout branch
git checkout -B $branchName
# Checkout master for mainline calculation
git checkout master
# Checkout branch again
git checkout $branchName

this saved some of our time, thanks!

I had this issue as well. For me, the issue was that the build server (TFS) did not have master or the branch checked out, rather it was operating in detached head state. Normally, GitVersion is smart enough to detect this condition, but it is powerless to do so in a Docker container.

I was able to work around the issue using a bash script like this (please note that the $(...) looking variables are TFS specific variables):

branchName="$(Build.SourceBranchName)"

if [ -n "$(System.PullRequest.PullRequestId)" ]
then
  branchName="PullRequest$(System.PullRequest.PullRequestId)"
fi

# Checkout branch
git checkout -B $branchName
# Checkout master for mainline calculation
git checkout master
# Checkout branch again
git checkout $branchName

I was able to get past this by changing from Mainline to ContinuousDelivery