Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pipelines/templates/release-validate-packagenames.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- pwsh: |
$message = @()
Get-ChildItem $(System.ArtifactsDirectory)\* -recurse -filter *.pkg | ForEach-Object {
if($_.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx(\.10\.12)?\-(x64|arm64)\.pkg')
if($_.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg')
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The regex pattern uses an unescaped . which matches any character, not just a literal dot. In the pattern [a-z]*., the dot should be escaped as \. to specifically match the dot in version suffixes like "preview.6" or "rebuild.5".

Currently, the pattern would incorrectly match malformed names like:

Fix: Escape the dot in the pattern:

if($_.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*\.\d+\-)?osx\-(x64|arm64)\.pkg')
Suggested change
if($_.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg')
if($_.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*\.\d+\-)?osx\-(x64|arm64)\.pkg')

Copilot uses AI. Check for mistakes.
{
$messageInstance = "$($_.Name) is not a valid package name"
$message += $messageInstance
Expand Down
11 changes: 6 additions & 5 deletions test/packaging/macos/package-validation.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ Describe "Verify macOS Package" {
$script:package | Should -Not -BeNullOrEmpty

# Regex pattern for valid macOS PKG package names.
# This pattern matches the validation used in release-validate-packagenames.yml
# Valid examples:
# - powershell-7.4.13-osx-x64.pkg (Intel x64 - note: x64 with hyphens for compatibility)
# - powershell-7.4.13-osx-arm64.pkg (Apple Silicon)
# - powershell-preview-7.6.0-preview.6-osx-x64.pkg
# - powershell-lts-7.4.13-osx-arm64.pkg
$pkgPackageNamePattern = '^powershell(-preview|-lts)?-\d+\.\d+\.\d+(-[a-z]+\.\d+)?-osx-(x64|arm64)\.pkg$'
# - powershell-7.4.13-osx-x64.pkg (Stable release)
# - powershell-7.6.0-preview.6-osx-x64.pkg (Preview version string)
# - powershell-7.4.13-rebuild.5-osx-arm64.pkg (Rebuild version)
# - powershell-lts-7.4.13-osx-arm64.pkg (LTS package)
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg$'
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The regex pattern uses an unescaped . which matches any character, not just a literal dot. In the pattern [a-z]*., the dot should be escaped as \. to specifically match the dot in version suffixes like "preview.6" or "rebuild.5".

Currently, the pattern would incorrectly match malformed names like:

Fix: Escape the dot in the pattern:

$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*\.\d+\-)?osx\-(x64|arm64)\.pkg$'
Suggested change
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg$'
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*\.\d+\-)?osx\-(x64|arm64)\.pkg$'

Copilot uses AI. Check for mistakes.

$script:package.Name | Should -Match $pkgPackageNamePattern -Because "Package name should follow the standard naming convention"
}
Expand Down
9 changes: 3 additions & 6 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1145,15 +1145,12 @@ function New-UnixPackage {
}

# Determine if the version is a preview version
$IsPreview = Test-IsPreview -Version $Version -IsLTS:$LTS

# Preview versions have preview in the name
# Only LTS packages get a prefix in the name
# Preview versions are identified by the version string itself (e.g., 7.6.0-preview.6)
# Rebuild versions are also identified by the version string (e.g., 7.4.13-rebuild.5)
Comment on lines 1147 to +1150
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Critical Bug: This change removes the $IsPreview variable assignment, but the variable is still used later in the function on lines 1168, 1184, and 1198, causing an undefined variable error.

The change correctly removes "powershell-preview" from package naming, but incorrectly removes the $IsPreview variable that's needed for:

  • Installation path suffix determination (line 1168: $Suffix = if ($IsPreview) { ... })
  • Executable path generation (line 1184: Get-PwshExecutablePath -IsPreview:$IsPreview)
  • Man page generation (line 1198: New-ManGzip -IsPreview:$IsPreview -IsLTS:$LTS)

Fix: Restore the removed lines:

$IsPreview = Test-IsPreview -Version $Version -IsLTS:$LTS

These lines should remain because the variable is needed for installation behavior, even though package naming no longer uses the preview prefix.

Copilot uses AI. Check for mistakes.
$Name = if($LTS) {
"powershell-lts"
}
elseif ($IsPreview) {
"powershell-preview"
}
else {
"powershell"
}
Expand Down
Loading