From dd6f0d2df48c3beddf2fb5dc64aaa12313059aca Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Thu, 9 Jul 2026 16:15:16 +0200 Subject: [PATCH] Fix dependency resolution when branch name contains ']' character GetDependencies enumerated the resolved dependency folder with Get-ChildItem -Path, which treats ']' (allowed in git branch names) as a wildcard metacharacter and returns the folder itself instead of the contained .app files. This caused 0 apps to be published. Use -LiteralPath since the folder is already resolved. --- Actions/Github-Helper.psm1 | 3 ++- RELEASENOTES.md | 1 + Tests/GitHub-Helper.Test.ps1 | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Actions/Github-Helper.psm1 b/Actions/Github-Helper.psm1 index 27766856c..3c93fed5c 100644 --- a/Actions/Github-Helper.psm1 +++ b/Actions/Github-Helper.psm1 @@ -167,7 +167,8 @@ function GetDependencies { if (Test-Path $downloadName -PathType Container) { $folder = Get-Item $downloadName - Get-ChildItem -Path $folder | ForEach-Object { + # -LiteralPath: $folder is already resolved and may contain wildcard chars (e.g. ']' from a branch name) + Get-ChildItem -LiteralPath $folder | ForEach-Object { if ($currentMask -like '*TestApps') { $downloadedList += @("($($_.FullName))") } diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 75efaed77..71589168e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,6 +1,7 @@ ### Issues - Fix "filename or extension is too long" error when validating settings on PS5.1 with large settings JSON +- Fix dependency apps not being resolved when the branch name contains a `]` character (the dependency folder was matched as a wildcard pattern instead of enumerated literally, resulting in 0 apps being published) ## v9.1 diff --git a/Tests/GitHub-Helper.Test.ps1 b/Tests/GitHub-Helper.Test.ps1 index abae8f4d5..431969d16 100644 --- a/Tests/GitHub-Helper.Test.ps1 +++ b/Tests/GitHub-Helper.Test.ps1 @@ -232,4 +232,36 @@ Describe "GitHub-Helper Tests" { $result = GetLatestRelease -token 'dummy' -api_url 'https://api.github.com' -repository 'test/repo' -ref 'releases/v26x' $result.tag_name | Should -Be '26.3.0' } + + It 'GetDependencies resolves .app files when the dependency folder path contains a glob metacharacter (])' { + # A branch name may contain ']' (git forbids '[' but allows ']'), which ends up in the + # downloaded dependency folder name. GetDependencies must enumerate that folder with + # -LiteralPath; using -Path would treat ']' as a wildcard and return the folder itself + # instead of the .app files inside it. + $saveToPath = (New-Item -ItemType Directory -Path (Join-Path $([System.IO.Path]::GetTempPath()) $([System.IO.Path]::GetRandomFileName()))).FullName + try { + $branch = 'bugs_Bug-638182--master]-Postserviceorder' + $depFolder = New-Item -ItemType Directory -Path (Join-Path $saveToPath "MyProj-$branch-Apps-PR1-20260709") + [System.IO.File]::WriteAllBytes((Join-Path $depFolder "App1.app"), [byte[]](1, 2, 3)) + [System.IO.File]::WriteAllBytes((Join-Path $depFolder "App2.app"), [byte[]](4, 5, 6)) + + $probingPath = [PSCustomObject]@{ + release_status = 'thisBuild' + buildMode = 'Default' + projects = 'MyProj' + branch = $branch + repo = 'https://github.com/test/repo' + } + + $result = @(GetDependencies -probingPathsJson $probingPath -saveToPath $saveToPath -masks @('Apps')) + + $result | Should -HaveCount 2 + $result | ForEach-Object { $_ | Should -BeLike '*.app' } + $result | Should -Contain (Join-Path $depFolder "App1.app") + $result | Should -Contain (Join-Path $depFolder "App2.app") + } + finally { + Remove-Item -Path $saveToPath -Recurse -Force -ErrorAction SilentlyContinue + } + } }