Skip to content

Fix PSVersionTable tag GitCommitId test#27523

Open
KirtiRamchandani wants to merge 2 commits into
PowerShell:masterfrom
KirtiRamchandani:fix/psversiontable-tag-gitcommitid
Open

Fix PSVersionTable tag GitCommitId test#27523
KirtiRamchandani wants to merge 2 commits into
PowerShell:masterfrom
KirtiRamchandani:fix/psversiontable-tag-gitcommitid

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

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

Copilot AI review requested due to automatic review settings May 25, 2026 01:11
@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner May 25, 2026 01:11
$PSVersionTable.GitCommitId | Should -Match $expectedGitCommitIdPattern
$PSVersionTable.GitCommitId | Should -Not -Match $unexpectectGitCommitIdPattern
$PSVersionTable.GitCommitId | Should -BeExactly $rawGitCommitId
$expectedGitCommitIds.Contains($PSVersionTable.GitCommitId) | Should -BeTrue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$expectedGitCommitIds.Contains($PSVersionTable.GitCommitId) | Should -BeTrue
$PSVersionTable.GitCommitId | Should -BeIn $expectedGitCommitIds

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

I think this change would be good for clarity. Other than that LGTM

@KirtiRamchandani

Copy link
Copy Markdown
Author

@jshigetomi OK, done. Ty, it matches the pester style. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSVersionTable.Tests.ps1 handles certain builds incorrectly.

2 participants