Prevent wildcard expansion in git sparse checkout add (#2745)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-08-16 10:00:54 -07:00 committed by GitHub
parent 8d0e4dfd1c
commit b62de00276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,8 +25,6 @@ steps:
script: |
function SparseCheckout([Array]$paths, [Hashtable]$repository)
{
$paths = $paths -Join ' '
$dir = $repository.WorkingDirectory
if (!$dir) {
$dir = "./$($repository.Name)"
@ -50,7 +48,9 @@ steps:
git sparse-checkout set '/*' '!/*/' '/eng'
}
$gitsparsecmd = "git sparse-checkout add $paths"
# Prevent wildcard expansion in Invoke-Expression (e.g. for checkout path '/*')
$quotedPaths = $paths | ForEach-Object { "'$_'" }
$gitsparsecmd = "git sparse-checkout add $quotedPaths"
Write-Host $gitsparsecmd
Invoke-Expression -Command $gitsparsecmd