Fix PSVersionTable tag GitCommitId test by KirtiRamchandani · Pull Request #27523 · PowerShell/PowerShell
PR Summary
Update PSVersionTable.Tests.ps1 so tag builds accept both valid GitCommitId forms:
- release tag builds that report only the semantic version, such as
7.6.2 - clean tag builds that report the
git describe --longform, such as7.6.2-0-g<sha>
PR Context
ProductVersion for a tag build can include SHA: <sha> even when the built GitCommitId is 7.6.2-0-g<sha>. The previous test treated the -0-g<sha> form as unexpected whenever ProductVersion did not include Commits:, which makes the test fail for clean builds from a release tag.
This keeps the exact check for normal commit builds, strips any +<source revision> suffix from the product-version SHA before comparing, and adds regression coverage for the zero-commit tag case.
Fixes #27503
PR Checklist
- PR has a meaningful title
- Summarized changes
- Make sure all
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header - This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
- Breaking changes
- None
- User-facing changes
- Not Applicable
- Testing - New and feature
- Added regression coverage for tag builds with zero commits
Tests
Start-PSBootstrap -Scenario DotnetStart-PSBuild -UseNuGetOrg -SkipExperimentalFeatureGenerationStart-PSPester -Path ./test/powershell/Host/PSVersionTable.Tests.ps1 -UseNuGetOrg -SkipTestToolBuild -ThrowOnFailure(16 passed)git diff --check