Implement versioned calculation and output configuration - #5158
Conversation
5f5d629 to
eb5b85a
Compare
eb5b85a to
294eb09
Compare
294eb09 to
8d5f4bd
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces broad, version-dependent configuration parsing/serialization and CLI override behavior changes across multiple subsystems, warranting final human review despite test updates.
Pull request overview
This PR introduces a version-aware GitVersion configuration model by splitting settings into nested calculation and output sections, with runtime selection controlled by GITVERSION_CONFIGURATION_VERSION (defaulting to v7 while retaining v6 compatibility via explicit selection). It updates configuration serialization/deserialization, workflow docs/baselines, CLI/MSBuild override parsing, and cache key computation to ensure consistent behavior across both structures.
Changes:
- Added version selection (
v6/v7) and normalization/mapping between nested and flat configuration documents. - Split configuration surface area into new
ICalculation*andIOutput*interfaces and updated builders/serialization accordingly. - Updated override-config parsing/validation, cache keys, tests, workflow baselines, and docs to reflect the nested structure.
File summaries
| File | Description |
|---|---|
| src/GitVersion.MsBuild.Tests/Tasks/WriteVersionInfoTest.cs | Update MSBuild test YAML to nested config |
| src/GitVersion.Core/VersionCalculation/Caching/GitVersionCacheKeyFactory.cs | Include configuration-version in cache key |
| src/GitVersion.Core/PublicAPI.Unshipped.txt | Record new public interfaces for API analyzers |
| src/GitVersion.Core/Configuration/IOutputConfiguration.cs | New output configuration interface |
| src/GitVersion.Core/Configuration/IOutputBranchConfiguration.cs | New output branch configuration interface |
| src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs | Add Calculation/Output to top-level config |
| src/GitVersion.Core/Configuration/ICalculationConfiguration.cs | New calculation configuration interface |
| src/GitVersion.Core/Configuration/ICalculationBranchConfiguration.cs | New calculation branch configuration interface |
| src/GitVersion.Core/Configuration/IBranchConfiguration.cs | Make branch config extend calc+output branch interfaces |
| src/GitVersion.Core/Configuration/ConfigurationVersion.cs | Add version selector based on env var |
| src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs | Cache invalidation test for config version changes |
| src/GitVersion.Core.Tests/Core/ConfigurationVersionSelectorTests.cs | Unit tests for selector parsing/fail-fast behavior |
| src/GitVersion.Configuration/GitVersionConfiguration.cs | Add Calculation/Output facades and cached projections |
| src/GitVersion.Configuration/ConfigurationSerializer.cs | Version-aware read/serialize with nesting/flattening |
| src/GitVersion.Configuration/ConfigurationProvider.cs | Normalize file/workflow/override inputs by version |
| src/GitVersion.Configuration/ConfigurationHelper.cs | Force legacy serialization for helper scenarios |
| src/GitVersion.Configuration/ConfigurationDocumentMapper.cs | New mapper: detect/flatten/nest + ownership validation |
| src/GitVersion.Configuration/Builders/ConfigurationBuilderBase.cs | Read from Calculation/Output when copying config |
| src/GitVersion.Configuration/BranchConfiguration.cs | Add explicit interface projections for calc branch members |
| src/GitVersion.Configuration.Tests/Workflows/approved/TrunkBased/preview1.yml | Approved baseline updated to nested structure |
| src/GitVersion.Configuration.Tests/Workflows/approved/GitHubFlow/v1.yml | Approved baseline updated to nested structure |
| src/GitVersion.Configuration.Tests/Workflows/approved/GitFlow/v1.yml | Approved baseline updated to nested structure |
| src/GitVersion.Configuration.Tests/Configuration/IgnoreConfigurationTests.cs | Tests updated to new configuration read path/versioning |
| src/GitVersion.Configuration.Tests/Configuration/ConfigurationSerializerTests.cs | Tests for v6/v7 serialization and projection caching |
| src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs | Tests for merging, parity, and mismatch detection |
| src/GitVersion.Configuration.Tests/Configuration/ConfigurationDocumentMapperTests.cs | New tests for mapping rules and ownership validation |
| src/GitVersion.Configuration.Tests/AssemblyParallelizable.cs | Disable parallelization (env-var sensitive tests) |
| src/GitVersion.App/OverrideConfigurationOptionParser.cs | Version-aware override path validation + nested dictionary output |
| src/GitVersion.App/LegacyArgumentParser.cs | Route override parsing through new batch validator |
| src/GitVersion.App/GitVersionExecutor.cs | Treat ConfigurationException like WarningException + stderr output |
| src/GitVersion.App/ArgumentParser.cs | Route override parsing through new batch validator |
| src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs | Update embedded config snippet to nested format |
| src/GitVersion.App.Tests/LegacyArgumentParserTests.cs | Add tests for v6/v7 override paths and replacements |
| src/GitVersion.App.Tests/ConfigurationVersionIntegrationTests.cs | New integration tests for parity and error output |
| src/GitVersion.App.Tests/ArgumentParserTests.cs | Add tests for nested override paths, casing, dotted branch rejection |
| docs/input/docs/workflows/TrunkBased/preview1.yml | Docs workflow YAML updated to nested format |
| docs/input/docs/workflows/GitHubFlow/v1.yml | Docs workflow YAML updated to nested format |
| docs/input/docs/workflows/GitFlow/v1.yml | Docs workflow YAML updated to nested format |
| docs/input/docs/reference/mdsource/configuration.source.md | Update example snippet to nested calculation section |
| docs/input/docs/reference/configuration.md | Update reference content/snippets for nested structure |
| .gitversion.yml | Repo’s own config migrated to nested structure |
| .github/workflows/docs.yml | Cache key includes .gitversion.yml |
| .github/workflows/_prepare.yml | Cache key includes .gitversion.yml |
| .github/actions/cache-restore/action.yml | Cache key includes .gitversion.yml |
Review details
- Files reviewed: 44/44 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8d5f4bd to
609b592
Compare
There was a problem hiding this comment.
🟡 Changes recommended
src/GitVersion.Configuration/GitVersionConfiguration.cs contains malformed ToDictionary lambda expressions that will not compile.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
src/GitVersion.Configuration/GitVersionConfiguration.cs:180
- This
ToDictionaryvalue selector is malformed (ICalculationBranchConfiguration (element) => ...) and will not compile. It should cast the branch config value toICalculationBranchConfiguration.
src/GitVersion.Configuration/GitVersionConfiguration.cs:210 - This
ToDictionaryvalue selector is malformed (IOutputBranchConfiguration (element) => ...) and will not compile. It should castelement.ValuetoIOutputBranchConfiguration.
- Files reviewed: 44/44 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
It changes configuration shape, selection, normalization, override parsing, and caching across multiple entry points, which warrants final human review despite strong test coverage.
Review details
- Files reviewed: 44/44 changed files
- Comments generated: 0 new
- Review effort level: Lite
asbjornu
left a comment
There was a problem hiding this comment.
As I wrote in #5160 (review); with accompanying new gitversion calculate and gitversion output commands, I support these configuration changes! 👍🏼
|
Tick the box to add this pull request to the merge queue (same as
|
609b592 to
5fc9820
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The docs and .gitversion.yml currently demonstrate/encode workflow nested under calculation, which contradicts the v7 root-level workflow requirement and will produce invalid configurations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 47/47 changed files
- Comments generated: 3
- Review effort level: Lite
5fc9820 to
09f1be0
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The Mixed-document diagnostic message is misleading for certain nested-doc root-key combinations and should be clarified before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 47/47 changed files
- Comments generated: 1
- Review effort level: Lite
09f1be0 to
7cb5933
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The change spans configuration modeling, public API surface, schema generation, CLI/MSBuild behavior, caching, and docs/tests, making it high-impact and better suited for final human verification.
Review details
- Files reviewed: 47/47 changed files
- Comments generated: 0 new
- Review effort level: Lite
7cb5933 to
88af5c8
Compare
|
There was a problem hiding this comment.
🟢 Approval recommended
The changes appear consistent across schema generation, configuration mapping/serialization, CLI overrides, caching, and tests/docs, with coverage added for version selection and mismatch scenarios.
Review details
- Files reviewed: 47/47 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Thank you @arturcic for your contribution! |



Summary
workflowpreset selector and separatecalculationandoutputsections.Validation
Closes #5132