GitVersion: [Bug] Null Exception

Describe the bug Error: The process ‘/opt/hostedtoolcache/GitVersion.Tool/5.7.0/x64/dotnet-gitversion’ failed with exit code 1

Expected Behavior

output JSON

Actual Behavior

Error: The process ‘/opt/hostedtoolcache/GitVersion.Tool/5.7.0/x64/dotnet-gitversion’ failed with exit code 1

Possible Fix

Steps to Reproduce

Context

I can’t use gitversion in my CI/CD

Your Environment

  • Version Used: 5.x - latest
  • Operating System and version (Windows 10, Ubuntu 18.04): Ubuntu 20.04
  • Link to your project:
  • Link to your CI build (if appropriate):
  ERROR [08/27/21 3:34:09:55] An unexpected error occurred:
System.NullReferenceException: Object reference not set to an instance of an object.
   at GitVersion.GitObject..ctor(GitObject innerGitObject) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitObject.cs:line 14
   at GitVersion.Commit..ctor(Commit innerCommit) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\Commit.cs:line 15
   at GitVersion.GitRepository.<>c__DisplayClass27_0.<FindMergeBase>b__0() in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 64
   at Polly.Policy`1.<>c__DisplayClass11_0.<Execute>b__0(Context ctx, CancellationToken ct)
   at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Action`4 onRetry, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider)
   at Polly.Retry.RetryPolicy`1.Implementation(Func`3 action, Context context, CancellationToken cancellationToken)
   at Polly.Policy`1.Execute(Func`3 action, Context context, CancellationToken cancellationToken)
   at Polly.Policy`1.Execute(Func`1 action)
   at GitVersion.Helpers.RetryAction`2.Execute(Func`1 operation) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Helpers\RetryAction.cs:line 37
   at GitVersion.GitRepository.FindMergeBase(ICommit commit, ICommit otherCommit) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 62
   at GitVersion.RepositoryStore.FindMergeBase(IBranch branch, IBranch otherBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 48
   at GitVersion.RepositoryStore.<>c__DisplayClass29_0.<GetMergeCommitsForBranch>b__2(IBranch otherBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 454
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToArray()
   at System.Linq.OrderedEnumerable`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at GitVersion.RepositoryStore.GetMergeCommitsForBranch(IBranch branch, Config configuration, IEnumerable`1 excludedBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 438
   at GitVersion.RepositoryStore.FindCommitBranchWasBranchedFrom(IBranch branch, Config configuration, IBranch[] excludedBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 321
   at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(IBranch targetBranch, BranchConfig branchConfiguration, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 81
   at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfiguration(IBranch targetBranch, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 47
   at GitVersion.GitVersionContextFactory.Create(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionContextFactory.cs:line 40
   at GitVersion.GitVersionCoreModule.<>c__DisplayClass0_0.<RegisterTypes>b__1() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\GitVersionCoreModule.cs:line 38
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at GitVersion.VersionCalculation.NextVersionCalculator.get_context() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 17
   at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 32
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 52
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 70
  INFO [08/27/21 3:34:09:55] Attempting to show the current git graph (please include in issue): 
  INFO [08/27/21 3:34:09:55] Showing max of 100 commits
  INFO [08/27/21 3:34:09:61] * e94028f 26 minutes ago  (HEAD -> build, origin/master, master)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I tried the latest build and there are still more null protection required. Please let me know if you want me to open new issue. ERROR [04/04/22 21:18:52:16] An unexpected error occurred: System.NullReferenceException: Object reference not set to an instance of an object. at GitVersion.RepositoryStore.<>c.<GetMergeCommitsForBranch>b__37_3(BranchCommit b) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Core/RepositoryStore.cs:line 504 at System.Linq.EnumerableSorter2.ComputeKeys(TElement[] elements, Int32 count) at System.Linq.EnumerableSorter1.ComputeMap(TElement[] elements, Int32 count) at System.Linq.EnumerableSorter1.Sort(TElement[] elements, Int32 count) at System.Linq.OrderedEnumerable1.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at GitVersion.RepositoryStore.GetMergeCommitsForBranch(IBranch branch, Config configuration, IEnumerable1 excludedBranches) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Core/RepositoryStore.cs:line 483 at GitVersion.RepositoryStore.FindCommitBranchWasBranchedFrom(IBranch branch, Config configuration, IBranch[] excludedBranches) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Core/RepositoryStore.cs:line 321 at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(Int32 recursions, IBranch targetBranch, BranchConfig branchConfiguration, ICommit currentCommit, Config configuration, IList1 excludedInheritBranches) at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfigurationInternal(Int32 recursions, IBranch targetBranch, ICommit currentCommit, Config configuration, IList1 excludedInheritBranches) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Configuration/BranchConfigurationCalculator.cs:line 54 at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfiguration(IBranch targetBranch, ICommit currentCommit, Config configuration, IList1 excludedInheritBranches) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Configuration/BranchConfigurationCalculator.cs:line 28 at GitVersion.GitVersionContextFactory.Create(GitVersionOptions gitVersionOptions) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Core/GitVersionContextFactory.cs:line 38 at GitVersion.GitVersionCoreModule.<>c__DisplayClass0_0.<RegisterTypes>b__1() in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/GitVersionCoreModule.cs:line 37 at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at System.Lazy`1.get_Value() at GitVersion.VersionCalculation.NextVersionCalculator.get_context() in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs:line 15 at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs:line 30 at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 52 at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /Users/runner/work/GitVersion/GitVersion/src/GitVersion.App/GitVersionExecutor.cs:line 66 INFO [04/04/22 21:18:52:16] Attempting to show the current git graph (please include in issue): INFO [04/04/22 21:18:52:16] Showing max of 100 commits INFO [04/04/22 21:18:52:26] * 1aeae519 4 hours ago (origin/ss/ps_enum)