Skip to content

Commit c47f65f

Browse files
committed
post-deployment-script: fix regex for sha256
There was a bug in the regex that finds the sha256 hash corresponding to the Git binary. Doing things like [Regex]::Escape directly in a string interpolation, apparently isn't supported by PowerShell This has surprisingly worked until now, because `Git-2.47.1-64-bit.exe` was always the first binary in the list of assets. Now that we're getting the native `-arm64.exe` binary, the bug in the logic got exposed. This commit fixes the bug by assigning the escaped asset name to a dedicated variable first. Signed-off-by: Dennis Ameling <[email protected]>
1 parent ff214a4 commit c47f65f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

azure-self-hosted-runners/post-deployment-script.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Write-Output "Starting post-deployment script."
5252
try {
5353
[System.Object]$GithubRestData = Invoke-RestMethod -Uri $GitHubUrl -Method Get -Headers $GithubHeaders -TimeoutSec 10 | Select-Object -Property assets, body
5454
[System.Object]$GitHubAsset = $GithubRestData.assets | Where-Object { $_.name -match $GithubExeName }
55-
if ($GithubRestData.body -match "\b${[Regex]::Escape($GitHubAsset.name)}.*?\|.*?([a-zA-Z0-9]{64})" -eq $True) {
55+
$AssetNameEscaped = [Regex]::Escape($GitHubAsset.name)
56+
if ($GithubRestData.body -match "\b${AssetNameEscaped}.*?\|.*?([a-zA-Z0-9]{64})" -eq $True) {
5657
[System.Object]$GitHubGit = [PSCustomObject]@{
5758
DownloadUrl = [string]$GitHubAsset.browser_download_url
5859
Hash = [string]$Matches[1].ToUpper()

0 commit comments

Comments
 (0)