◐ Shell
clean mode source ↗

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 --long form, such as 7.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

Tests

  • Start-PSBootstrap -Scenario Dotnet
  • Start-PSBuild -UseNuGetOrg -SkipExperimentalFeatureGeneration
  • Start-PSPester -Path ./test/powershell/Host/PSVersionTable.Tests.ps1 -UseNuGetOrg -SkipTestToolBuild -ThrowOnFailure (16 passed)
  • git diff --check