Closed rafek1241 closed 2 years ago
Okay, rebase to master fixed the issue but it could be great to have such custom exception here to be more described.
If you are able to provide a public repository that reproduces this problem, it should be easy to fix. We don't want NullReferenceException
to be thrown anywhere, as I completely agree they are obscure and unhelpful.
@asbjornu It was my work repository. I will try to prepare some reproduction repository soon.
@asbjornu Repository that reproduces the issue: https://github.com/rafek1241/gitversion-issue-2967-reproduction
I'm getting this issue with a private repo, so can help validate a fix if needed.
@davidkeaveny, can you please clone or fork GitVersion locally and run it against your repository to get a line numbered stack trace? If you're adventurous, it would be awesome if you found the source of the NRE and fixed it too.
I think I've managed to find the source of the issue you're experiencing, @rafek1241. As I'm not using Mainline myself, I'm not sure why this code is exactly as it is, but this line in RepositoryStore.GetMainlineBranches()
is excluding all branches that don't have a MergeBase
:
And for the reproduction repository you've provided, no branches have a MergeBase
, causing the returned list to become empty. What's worrying is that while commenting that line out still fails on your repository, it fails no tests. So our test coverage on Mainline is obviously not great. 😬
What I think could work here is for Mainline to defer to BaseVersionCalculator
if it's unable to find a suitable Mainline branch.
I think I've solved this in #3018. I still need to add a test and it should be good to go. I'm not yet confident that I'm able to reproduce the problem in a test, though.
:tada: This issue has been resolved in version 5.8.3 :tada: The release is available on:
Your GitReleaseManager bot :package::rocket:
This just happend to me again. A rebase had no impact. I'm on a feature-branch that has been squashed down to 1 commit.
System.NullReferenceException: Object reference not set to an instance of an object.
at LibGit2Sharp.Core.Handles.ObjectHandle.op_Implicit(ObjectHandle handle) in /_/LibGit2Sharp/Core/Handles/Objects.cs:line 509
at LibGit2Sharp.Core.Proxy.git_commit_author(ObjectHandle obj) in /_/LibGit2Sharp/Core/Proxy.cs:line 289
at LibGit2Sharp.Core.LazyGroup`1.Dependent`2.LibGit2Sharp.Core.LazyGroup<T>.IEvaluator<TInput>.Evaluate(TInput input) in /_/LibGit2Sharp/Core/LazyGroup.cs:line 88
at LibGit2Sharp.Core.LazyGroup`1.<Evaluate>b__6_0(T input) in /_/LibGit2Sharp/Core/LazyGroup.cs:line 36
at LibGit2Sharp.Core.GitObjectLazyGroup.EvaluateInternal(Action`1 evaluator) in /_/LibGit2Sharp/Core/GitObjectLazyGroup.cs:line 20
at LibGit2Sharp.Core.LazyGroup`1.Evaluate() in /_/LibGit2Sharp/Core/LazyGroup.cs:line 34
at LibGit2Sharp.Core.LazyGroup`1.Dependent`2.Evaluate() in /_/LibGit2Sharp/Core/LazyGroup.cs:line 80
at LibGit2Sharp.Core.LazyGroup`1.Dependent`2.get_Value() in /_/LibGit2Sharp/Core/LazyGroup.cs:line 73
at LibGit2Sharp.Commit.get_Committer() in /_/LibGit2Sharp/Commit.cs:line 87
at GitVersion.Commit..ctor(Commit innerCommit) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\Commit.cs:line 17
at GitVersion.Commit.<>c.<.ctor>b__3_0(Commit parent) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\Commit.cs:line 16
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(Int32 recursions, IBranch targetBranch, BranchConfig branchConfiguration, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 77
at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfigurationInternal(Int32 recursions, IBranch targetBranch, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 54
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 28
at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion()
at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 56
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line [52](_gitlab_url_masked_/-/jobs/4983096#L52)
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
INFO [07/17/24 9:05:56:63] Attempting to show the current git graph (please include in issue):
INFO [07/17/24 9:05:56:63] Showing max of 100 commits
....
It has been executed on a gitlab-runner. Will get another machine to test just to be sure the issue is not local.
I'm on 5.12.0
@0000day try the latest beta
Latest beta had too many changes for me. Investigated it on v5.12.0. The issue was that we moved over to Gitlab. Looks like gitlab is doing a shallow-copy of the repository.
before_script:
- git fetch --unshallow --all
This fixed it for me, maybe it's a help for others.
Describe the bug Branch version solving does not works
Expected Behavior
Correct composition of current version
Actual Behavior
Steps to Reproduce
I used command line execution in my project directory:
I tried as well with:
Your Environment
project that runs .net core 3.1
Branch structure in my repository:
Rider: