Avoid adding the same package twice, use TrimStart instead of substring (#5956)

Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
This commit is contained in:
Azure SDK Bot 2024-09-03 15:51:44 -07:00 committed by GitHub
parent e636fc5f3e
commit 14e5fcd057
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -119,7 +119,7 @@ function Get-PrPkgProperties([string]$InputDiffJson) {
foreach ($pkg in $allPackageProperties)
{
$pkgDirectory = Resolve-Path "$($pkg.DirectoryPath)"
$lookupKey = ($pkg.DirectoryPath).Replace($RepoRoot, "").SubString(1)
$lookupKey = ($pkg.DirectoryPath).Replace($RepoRoot, "").TrimStart('\/')
$lookup[$lookupKey] = $pkg
foreach ($file in $targetedFiles)
@ -132,12 +132,15 @@ function Get-PrPkgProperties([string]$InputDiffJson) {
if ($pkg.AdditionalValidationPackages) {
$additionalValidationPackages += $pkg.AdditionalValidationPackages
}
# avoid adding the same package multiple times
break
}
}
}
foreach ($addition in $additionalValidationPackages) {
$key = $addition.Replace($RepoRoot, "").SubString(1)
$key = $addition.Replace($RepoRoot, "").TrimStart('\/')
if ($lookup[$key]) {
$packagesWithChanges += $lookup[$key]