Repository navigation
[ISSUE]: NotImplementedException in TrunkBased-Workflow #4056
Description
Activity
Please analyze this issue in more detail and simplify your scenario. In advance provide:
- git commands and/or
- an integration test
to reproduce this issue.
Please notice: The
NotImplementedExceptionindecates that multipleis-main-branch: truebranches have been used with theMainlineversion 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.
GitVersion/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersionStrategy.cs
Lines 226 to 242 in a4dde97
if (item.IsMergeCommit()) { Lazy<IReadOnlyCollection<ICommit>> mergedCommitsInReverseOrderLazy = new( () => incrementStrategyFinder.GetMergedCommits(item, 1, Context.Configuration.Ignore).Reverse().ToList() ); if ((configuration.TrackMergeMessage ?? Context.Configuration.TrackMergeMessage) == true && MergeMessage.TryParse(item, Context.Configuration, out var mergeMessage)) { if (mergeMessage.MergedBranch is not null) { var childConfiguration = Context.Configuration.GetBranchConfiguration(mergeMessage.MergedBranch); var childBranchName = mergeMessage.MergedBranch; if (childConfiguration.IsMainBranch == true) { if (configuration.IsMainBranch == true) throw new NotImplementedException(); 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: mainfrom 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.
- 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
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 agoRepository you can test with:
https://github.com/thomhurst/GitVersionExceptionReproReacted by Stephen Reindl, Hardy Hobeck and ChrisMy 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
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 66Also happened to me with merge message
I got following errorSystem.NotImplementedException: The method or operation is not implemented. at GitVersion.VersionCalculation.MainlineVersionStrategy.IterateOverCommitsRecursive(IEnumerable`1 commitsInReverseOrder, MainlineIteration iteration, IBranch targetBranch, String targetLabel, ILookup`2 taggedSemanticVersions, HashSet`1 traversedCommits) in /_/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersionStrategy.cs:line 242 at GitVersion.VersionCalculation.MainlineVersionStrategy.GetBaseVersions(EffectiveBranchConfiguration configuration)+MoveNext() in /_/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MainlineVersionStrategy.cs:line 105 at GitVersion.VersionCalculation.NextVersionCalculator.<>c__DisplayClass14_0.<<GetNextVersions>g__GetNextVersionsInternal|0>d.MoveNext() in /_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.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/NextVersionCalculator.cs:line 239 at GitVersion.VersionCalculation.NextVersionCalculator.CalculateNextVersion(IBranch branch, IGitVersionConfiguration configuration) in /_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs:line 158 at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in /_/src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.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 INFO [24-11-04 11:48:58:98] Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*` to see the git graph. This can help you troubleshoot any issues.Just putting it out there for future reference.
I fixed it bytrack-merge-message: falseas I dont care about commit messages for version manipulationReacted by Matt Sharpe12 remaining items
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
Bump
Reacted by Nicholas Hastings, Jack-Hazelden-Blackdot, RJ Hollberg, Matt Sharpe and Guy PritchardEncountering more and more often, understand it is in preview but the trunk/mainline approach fits most development scenario's not mass versioned monoliths. And even those diverge from the other two variants.
Do we have any progress update(s)? This issue was opened 18 months ago.
Reacted by Guy Pritchard and lfossati-coreview@christopher1986, please see #4793.
Any chance we can get a release with this in?
- added a commit that references this issue
on Jan 30, 2026 🎉 This issue has been resolved in version 6.6.0 🎉
The release is available on:Your GitReleaseManager bot 📦🚀
- added 2 commits that reference this issue
on Mar 30, 2026
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).