GitVersion
GitVersion copied to clipboard
[ISSUE]: NotImplementedException in TrunkBased-Workflow
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched issues to ensure it has not already been reported
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:
workflow: TrunkBased/v1
patch-version-bump-message: "^(text|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
INFO [24-06-07 22:24:08:77] Applicable build agent found: 'LocalBuild'.
INFO [24-06-07 22:24:08:83] Working directory: /home/sreindl/src/mybook
INFO [24-06-07 22:24:08:83] Project root is: /home/sreindl/src/mybook/
INFO [24-06-07 22:24:08:83] DotGit directory is: /home/sreindl/src/mybook/.git
INFO [24-06-07 22:24:08:83] Branch from build environment:
INFO [24-06-07 22:24:08:84] Found configuration file at '/home/sreindl/src/mybook/GitVersion.yml'
INFO [24-06-07 22:24:08:86] -< Begin: Loading version variables from disk cache file /home/sreindl/src/mybook/.git/gitversion_cache/2E0243312D3E3098EEE3D1F4458494769E1ACE06 >-
INFO [24-06-07 22:24:08:86] Cache file /home/sreindl/src/mybook/.git/gitversion_cache/2E0243312D3E3098EEE3D1F4458494769E1ACE06 not found.
INFO [24-06-07 22:24:08:86] -< End: Loading version variables from disk cache file /home/sreindl/src/mybook/.git/gitversion_cache/2E0243312D3E3098EEE3D1F4458494769E1ACE06 (Took: 0.51ms) >-
INFO [24-06-07 22:24:08:86] Found configuration file at '/home/sreindl/src/mybook/GitVersion.yml'
INFO [24-06-07 22:24:09:01] Using latest commit on specified branch
INFO [24-06-07 22:24:09:03] Getting tagged semantic versions. TagPrefix: [vV]? and Format: Strict
INFO [24-06-07 22:24:09:09] Running against branch: main ('16af603' - Merge pull request #250 from steven-r/dependabot/npm_and_yarn/prettier-3.3.0)
INFO [24-06-07 22:24:09:09] -< Begin: Fetching the base versions for version calculation... >-
INFO [24-06-07 22:24:09:09] Calculating base versions for 'main'
INFO [24-06-07 22:24:09:09] -< Begin: [Using 'ConfiguredNextVersionVersionStrategy' strategy] >-
INFO [24-06-07 22:24:09:09] -< End: [Using 'ConfiguredNextVersionVersionStrategy' strategy] (Took: 0.51ms) >-
INFO [24-06-07 22:24:09:09] -< Begin: [Using 'MainlineVersionStrategy' strategy] >-
INFO [24-06-07 22:24:09:10] -< Begin: Getting tagged semantic versions on branch 'refs/heads/main'. TagPrefix: [vV]? and Format: Strict >-
INFO [24-06-07 22:24:09:12] -< End: Getting tagged semantic versions on branch 'refs/heads/main'. TagPrefix: [vV]? and Format: Strict (Took: 15.81ms) >-
INFO [24-06-07 22:24:09:14] -< Begin: Finding branches source of 'main' >-
INFO [24-06-07 22:24:09:14] -< End: Finding branches source of 'main' (Took: 5.23ms) >-
INFO [24-06-07 22:24:09:77] -< End: [Using 'MainlineVersionStrategy' strategy] (Took: 673.15ms) >-
INFO [24-06-07 22:24:09:77] -< End: Fetching the base versions for version calculation... (Took: 676.90ms) >-
ERROR [24-06-07 22:24:09:78] An unexpected error occurred:
System.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 62
INFO [24-06-07 22:24:09:78] Attempting to show the current git graph (please include in issue):
INFO [24-06-07 22:24:09:78] Showing max of 100 commits
INFO [24-06-07 22:24:09:81] * 16af603 4 days ago (HEAD -> main, origin/main, origin/HEAD)
|\
| * c78e95a 4 days ago
* | b059dc8 4 days ago
|\ \
| |/
|/|
| * d647992 4 days ago (origin/dependabot/pip/tools/watchdog-4.0.1)
* | 138cd6e 4 days ago
|\ \
| * | b5fd3e3 4 days ago
* | | f2133e2 4 days ago
|\ \ \
| * | | c85b925 4 days ago
| |/ /
* | | d941621 4 days ago
|\ \ \
| |/ /
|/| |
| * | a806d1a 4 days ago (origin/dependabot/pip/tools/python-dateutil-2.9.0.post0)
| |/
* | a7eb2de 4 days ago
|\ \
| * | cab75cb 4 days ago
|/ /
* | f7ab2bc 4 days ago
|\ \
| * | fe6dd26 4 days ago (origin/dependabot/npm_and_yarn/semantic-release-24.0.0)
| |/
* | 379206f 4 days ago
|\ \
| * | 32ef5c1 4 days ago (origin/dependabot/pip/tools/textual-0.64.0)
| |/
* | 4cbde78 4 days ago
* | 313c6a6 4 days ago
* | 8eedad5 4 days ago
* | 2b788e3 4 days ago
* | 1d16749 4 days ago
* | f8c9588 4 days ago
* | b675960 4 days ago
* | ad68f4c 5 days ago
|/
| * e924596 4 days ago (origin/dependabot/pip/tools/sphinx-design-0.6.0)
|/
| * 11ea42c 4 days ago (origin/dependabot/npm_and_yarn/typescript-5.4.5)
|/
| * 11785ed 4 days ago (origin/dependabot/npm_and_yarn/prettier-3.3.0)
|/
| * c523a3e 4 days ago (origin/dependabot/npm_and_yarn/conventional-changelog-conventionalcommits-8.0.0)
|/
* 095d235 5 days ago
* 1822eee 5 days ago
* 159b2de 5 days ago
* c467070 5 days ago
* 1c4511a 6 days ago
* b7d5a6e 6 days ago
* 54b0852 6 days ago
* 23db9fe 6 days ago
* e2127f2 6 days ago
* 3eafa11 6 days ago
* 1ad7fff 6 days ago
* 0413fe7 6 days ago
* be3e0b1 8 days ago
* cc15698 8 days ago
* cc15698 8 days ago
|\
| * d45724f 8 days ago
|/
* c4ed833 8 days ago
|\
| * caba933 8 days ago
|/
* bc10604 8 days ago
|\
| * d354534 4 months ago (origin/dependabot/npm_and_yarn/prettier-3.2.5)
* | 33783ca 8 days ago
|\ \
| * | d192163 4 months ago (origin/dependabot/npm_and_yarn/ip-2.0.1)
| |/
* | b1d0618 8 days ago
|\ \
| * | 25098ac 8 days ago
* | | a73a888 8 days ago
|\ \ \
| |/ /
|/| |
| * | 76d3474 8 days ago
* | | 33f72ce 8 days ago
|\ \ \
| |/ /
|/| |
| * | fb3290c 8 days ago
|/ /
* | dc2eb0b 12 days ago
* | dc229a8 12 days ago
* | 6bcd747 12 days ago
* | 882c286 12 days ago
* | 2a12144 12 days ago
* | 530eb9d 2 weeks ago
* | 2f8b873 2 weeks ago
* | 425c70b 2 weeks ago
|/
| * c6601dc 10 weeks ago (origin/dependabot/pip/tools/textual-0.55.0)
|/
| * 481f0fb 2 months ago (origin/dependabot/npm_and_yarn/semantic-release-23.0.6)
|/
| * bee859f 2 months ago (origin/dependabot/pip/tools/urwid-2.6.10)
|/
| * 783d5f4 3 months ago (origin/dependabot/pip/tools/setuptools-69.2.0)
|/
| * a868f1e 3 months ago (origin/dependabot/pip/tools/pandas-2.2.1)
|/
| * 407aec3 3 months ago (origin/dependabot/npm_and_yarn/eslint-8.57.0)
|/
| * 6a92988 4 months ago (origin/dependabot/npm_and_yarn/markdownlint-cli-0.39.0)
|/
| * 9fdb4b2 5 months ago (origin/dependabot/pip/tools/jinja2-3.1.3)
|/
| * a333d63 5 months ago (origin/dependabot/pip/tools/humanize-4.9.0)
|/
* d90c696 5 months ago
|\
| * 3a5505d 5 months ago
|/
* 0540c52 5 months ago
|\
| * 440e8f6 5 months ago
* | 1f401cb 5 months ago
|\ \
| |/
|/|
| * 83779f0 5 months ago
|/
* 5271152 5 months ago
|\
| * 97a7f28 5 months ago
|/
* 6be3236 5 months ago
|\
| * 907fe08 6 months ago
* | be2f03c 5 months ago
|\ \
| * | e1f6ab0 6 months ago
| |/
* | 860a2b5 5 months ago
|\ \
| * | 205ad0d 6 months ago
| |/
* | 4a5116c 5 months ago
|\ \
| * | 57760c5 7 months ago
| |/
* | 9484cc8 5 months ago
|\ \
| * | 7e3cf6d 7 months ago
| |/
* | ed7e81a 5 months ago
|\ \
| * | dcfd8e3 6 months ago
| |/
* | 22e49e4 5 months ago
|\ \
| |/
|/|
| * 6234f1d 5 months ago
|/
* b2d7db0 7 months ago
|\
| * e35f3a7 7 months ago
| |\
| | * 3d790ff 7 months ago
| * | b65376f 7 months ago
| |\ \
| | * | fb30953 8 months ago
| | |/
| * | dde8119 7 months ago
| |\ \
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 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:
- #4057
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.
- 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 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
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
Also happened to me with merge message I got following error
System.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 by track-merge-message: false as I dont care about commit messages for version manipulation
I'm stuck with the same problem on repositories with merge message. At the moment using track-merge-message: false fix the issue.
Is there an ETA or plan on the fix of this?
I've got auto-merged dependency updates in my repos, and if two automatically merge without rebasing in between it breaks GitVersioning every time.
I think this feature needs to be implemented:
- #4057
At the moment the above feature implementation has not started. Any pull-requests are appreciated.
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.
This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions
Can we re-open this? I know you say pull requests welcome but I don't have enough knowledge on how the algorithms or what-not work to generate everything, otherwise I'd try and contribute.
This is unfortunately still affecting a lot of my pipelines if things get merged without rebasing in-between.
Same here -- still fighting with this issue regularly. I'm currently having my team rebase instead of merging changes; but it's causing friction. I've used GitVersion for years with no problems; but suddenly it's failing us big-time. Better debug output at least would be helpful ...
One workaround is to just go back to version 5.x. It still generally works fine, including for this case
For now, we ended up just forking it internally for dependency updates
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
Encountering 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.