[WIP] Expose VersionSourceSemVer as Output Variable#4804
[WIP] Expose VersionSourceSemVer as Output Variable#4804jakublatkowski wants to merge 5 commits intoGitTools:mainfrom
Conversation
HHobeck
left a comment
There was a problem hiding this comment.
I think you need to update the following source in docs/input/docs/reference/variable.md.
src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/VersionCalculation/VersionCalculators/NextVersionCalculator.cs
Outdated
Show resolved
Hide resolved
|
@jakublatkowski please make sure you rebase your branch onto |
There was a problem hiding this comment.
Pull request overview
This PR exposes the VersionSourceSemVer variable as a standard output variable, making it available alongside existing version fields in environment variables, JSON output, and build agent-specific outputs. The VersionSourceSemVer represents the base semantic version calculated by GitVersion before any pre-release tags or metadata are applied.
Changes:
- Added
VersionSourceSemVerproperty to core data model classes (SemanticVersionBuildMetaData,SemanticVersionFormatValues,GitVersionVariables) - Updated version calculators to pass base version information instead of just commit references
- Modified deployment mode calculator interface to accept
IBaseVersioninstead ofICommit? - Updated all test files and approved test outputs to include the new variable
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/GitVersion.Core/SemVer/SemanticVersionBuildMetaData.cs |
Added VersionSourceSemVer property and updated constructor signature to accept it as first parameter |
src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs |
Added property to expose VersionSourceSemVer as string |
src/GitVersion.Core/OutputVariables/GitVersionVariables.cs |
Added VersionSourceSemVer to the output variables record |
src/GitVersion.Core/VersionCalculation/VariableProvider.cs |
Updated to pass VersionSourceSemVer when creating variables |
src/GitVersion.Core/VersionCalculation/VersionCalculators/VersionCalculatorBase.cs |
Modified to accept IBaseVersion and extract semantic version from it |
src/GitVersion.Core/VersionCalculation/VersionCalculators/*.cs |
Updated deployment mode calculators to use new IBaseVersion parameter |
src/GitVersion.Core/VersionCalculation/Abstractions/IDeploymentModeCalculator.cs |
Changed interface to accept IBaseVersion instead of ICommit? |
src/GitVersion.Core/PublicAPI.*.txt |
Documented breaking changes and new public API members |
src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs |
Added VersionSourceSemVer to JSON output model |
src/GitVersion.MsBuild/Tasks/GetVersion.cs |
Added VersionSourceSemVer output property to MSBuild task |
src/GitVersion.MsBuild/PublicAPI.Unshipped.txt |
Documented new MSBuild task property |
src/GitVersion.*.Tests/**/*.cs |
Updated all test files to use new constructor signature |
src/GitVersion.*.Tests/**/Approved/*.txt |
Updated all approved test outputs to include new variable |
docs/input/docs/reference/variables.md |
Added documentation for the new variable |
src/GitVersion.Output.Tests/Output/GitVersionInfoGeneratorTests.cs
Outdated
Show resolved
Hide resolved
5c9c087 to
6cbb005
Compare
|



This PR adds
VersionSourceSemVerto the standard output variables exposed by GitVersion.Description
This PR adds
VersionSourceSemVerto the standard output variables exposed by GitVersion, making it available alongside existing version fields in:GitVersion_VersionSourceSemVer)The
VersionSourceSemVerrepresents the base semantic version calculated by GitVersion before any pre-release tags or metadata are applied. This is the foundational version derived from the repository's version tags and configuration.Related Issue
This PR addresses a feature request for exposing VersionSourceSemVer in output variables.
Resolves #4803
Motivation and Context
The Problem
GitVersion determines the version by identifying a "Base Version" (from a tag, merge message, or branch config) and then incrementally applying rules to calculate the new version. While we currently expose the distance from this base (via CommitsSinceVersionSource), the BaseVersion itself is internal. Users verify this "anchor" point only by reading verbose logs, making it difficult to debug why a specific version was calculated or to perform logic based on the version calculation's starting point.
Why VersionSourceSemVer Matters
Workflow Flexibility: In strict tag-based workflows (like GitFlow), VersionSourceSemVer often correlates to the "previous release," enabling scripts to generate diffs or changelogs from that point.
Why This Change is Valuable
By exposing
VersionSourceSemVeras a standard output variable, we:How Has This Been Tested?
Unit Tests: Added/updated tests to verify:
Verification Steps
Screenshots (if appropriate):
Example JSON output showing the new
VersionSourceSemVerfield:{ "Major": 5, "Minor": 12, "Patch": 0, "SemVer": "5.12.0-beta.1", "FullSemVer": "5.12.0-beta.1+42", ... "VersionSourceSemVer": "5.12.0", ... }Additional Notes
This change is purely additive - it introduces a new output variable without modifying any existing behavior or outputs. The risk of regression is minimal, and it opens up new integration possibilities for teams using GitVersion in their CI/CD pipelines.
Checklist: