Open steven-r opened 4 months ago
Please analyze this issue in more detail and simplify your scenario. In advance provide:
to reproduce this issue.
Please notice: The NotImplementedException
indecates that multiple is-main-branch: true
branches have been used with the Mainline
version strategy. In version 6.x this is not supported and will be probably implemented in version 7.x:
When upgrading to 6 I've noticed the same stacktrace from the build server on merge commits, just trying to understand what the right config should be here... It looks like the solution is to either turn off "is-main-branch" (which seems to give the wrong version) or turn off "track-merge-message" to prevent that codepath in the merge build. https://github.com/GitTools/GitVersion/blob/a4dde97534bb504f8c41a2ca0c709f7cea12dae0/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersionStrategy.cs#L226-L242
I think this occurs when there is a merge message on te main branch. The childConfiguration is the same as the current configuration and the exception is thrown.
Tip: I removed regex: main
from the main branch definition in GitVersion.yml and this error went away.
After some digging, cloing the sources and add debug information I can confirm that these are merge requests towards Main coming from PRs. What fixed he problem was to add the malicious merges to the ignore list.
Anyhow, this git "tree" was a result out of working git operations. Instead of throwing an error/exception, gitversion should ignore those merges to behave like 5.x
@steven-r, sure. If you can figure out a way to ignore such commits without breaking any existing tests, we would be happy to accept a pull request.
@steven-r Can you please create a minimal example or somehow a visual representation to have a basis for the discussion? Would be very good.
Actually I'm not sure if a merge commit from main is generally a good idea in the TrunkBased workflow. Anyway ignoring the commit is not what I would expect. I would expect at least that it will be handled like a normal commit. What do you think?
I've just managed to replicate it.
Git Log output:
* b4587d0 2 minutes ago (HEAD -> main, origin/main, origin/HEAD)
|\
| * d8d918b 3 minutes ago
* | b69156a 2 minutes ago
|/
* c6c2e05 5 minutes ago
* 47c20f6 2 days ago
* df3ed2f 2 days ago
* 794b50f 2 days ago
Repository you can test with: https://github.com/thomhurst/GitVersionExceptionRepro
My real use case is a list of dependabot updates on main where there's no rebase in between (as it is not needed in all cases).
I've just managed to replicate it.
- I pull main
- Someone else commits and pushes to main
- I commit and push to main, but don't have the latest now
- Git merges latest for me and makes a commit with a message "[Merge remote-tracking branch 'origin/main']
- GitVersion now fails with exception
My real use case is a list of dependabot updates on main where there's no rebase in between (as it is not needed in all cases).
Yep this exact scenario has just broken my repository. Arghhhhhh
I've tried ignoring those commits and now I'm getting a brand new error:
INFO [24-09-06 16:46:10:80] -< End: Fetching the base versions for version
calculation... (Took: 7,416.53ms) >-
ERROR [24-09-06 16:46:10:81] An unexpected error occurred:
System.ArgumentOutOfRangeException: Exception of type
'System.ArgumentOutOfRangeException' was thrown. (Parameter 'strategy')
Actual value was Inherit.
at
GitVersion.Extensions.IncrementStrategyExtensions.ToVersionField(IncrementStrate
gy strategy) in
/_/src/GitVersion.Core/Extensions/IncrementStrategyExtensions.cs:line 11
at
GitVersion.VersionCalculation.Mainline.EnrichIncrement.Enrich(MainlineIteration
iteration, MainlineCommit commit, MainlineContext context) in
/_/src/GitVersion.Core/VersionCalculation/Mainline/EnrichIncrement.cs:line 13
at
GitVersion.VersionCalculation.MainlineVersionStrategy.GetIncrements(MainlineIter
ation iteration, String targetLabel, IIncrementStrategyFinder
incrementStrategyFinder, IGitVersionConfiguration configuration)+MoveNext() in
/_/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersio
nStrategy.cs:line 367
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1
items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1
source)
at
GitVersion.VersionCalculation.MainlineVersionStrategy.DetermineBaseVersionRecurs
ive(MainlineIteration iteration, String targetLabel, IIncrementStrategyFinder
incrementStrategyFinder, IGitVersionConfiguration configuration) in
/_/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersio
nStrategy.cs:line 335
at
GitVersion.VersionCalculation.MainlineVersionStrategy.DetermineBaseVersion(Mainl
ineIteration iteration, String targetLabel, IIncrementStrategyFinder
incrementStrategyFinder, IGitVersionConfiguration configuration) in
/_/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersio
nStrategy.cs:line 328
at
GitVersion.VersionCalculation.MainlineVersionStrategy.GetBaseVersions(EffectiveB
ranchConfiguration configuration)+MoveNext() in
/_/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersio
nStrategy.cs:line 113
at
GitVersion.VersionCalculation.NextVersionCalculator.<>c__DisplayClass14_0.<<GetN
extVersions>g__GetNextVersionsInternal|0>d.MoveNext() in
/_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculat
or.cs:line 264
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at
GitVersion.VersionCalculation.NextVersionCalculator.GetNextVersions(IBranch
branch, IGitVersionConfiguration configuration) in
/_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculat
or.cs:line 239
at
GitVersion.VersionCalculation.NextVersionCalculator.CalculateNextVersion(IBranch
branch, IGitVersionConfiguration configuration) in
/_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculat
or.cs:line 158
at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in
/_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculat
or.cs:line 53
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in
/_/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 45
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions
gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 66
Prerequisites
GitVersion package
GitVersion.Tool
GitVersion version
6.0.0-rc1
Operating system
Linux, Windows
What are you seeing?
When running gitversion on my git repos, I receive a
NotImplementedException
.I was using Mainline for the past and I'm trying out the 6.0-RC1 release now.
What is expected?
A valid version description.
Steps to Reproduce
use my repos (it's private, sorry), with the following configuration:
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).