Skip to content

Sequence contains more than one matching element #453

@richardwadsworth

Description

@richardwadsworth

I am getting this error from TeamCity running "GitVersion 3.0.0-beta0002":

HEAD is detached and points at commit 'ace660f968753ea2e455fecfdce799a17db12bf4'.
No local branch pointing at the commit 'ace660f968753ea2e455fecfdce799a17db12bf4'. Fake branch needs to be created.
Found remote tip 'refs/pull/5/merge' pointing at the commit 'ace660f968753ea2e455fecfdce799a17db12bf4'.
Creating fake local branch 'refs/heads/pull/5/merge'.
Checking local branch 'refs/heads/pull/5/merge' out.
No specific commit specified or found, falling back to latest commit on specified branch
Attempting to inherit branch configuration from parent branch
An unexpected error occurred:
System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration(Boolean onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair`2 keyValuePair, BranchConfig branchConfiguration, Config config) in c:\BuildAgent\work\5106452ed7682238\GitVersionCore\BranchConfigurationCalculator.cs:line 60
   at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration(Commit currentCommit, IRepository repository, Boolean onlyEvaluateTrackedBranches, Config config, Branch currentBranch) in c:\BuildAgent\work\5106452ed7682238\GitVersionCore\BranchConfigurationCalculator.cs:line 26
   at GitVersion.GitVersionContext.CalculateEffectiveConfiguration() in c:\BuildAgent\work\5106452ed7682238\GitVersionCore\GitVersionContext.cs:line 79
   at GitVersion.GitVersionContext..ctor(IRepository repository, Branch currentBranch, Config configuration, Boolean onlyEvaluateTrackedBranches, String commitId) in c:\BuildAgent\work\5106452ed7682238\GitVersionCore\GitVersionContext.cs:line 57
   at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
   at GitVersion.Program.VerifyArgumentsAndRun()

I created branch, committed and pushed, created a pull request against a branch and then committed an additional change to that branch.

GitVersion parses the original commit (2.0.1-abc.1+1), the first PR (2.0.1-PullRequest.5+2) and the second commit (2.0.1-abc.1+2) but throws the above exception when parsing the PR. There are 3 tags against the repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions