Skip to content
Prev Previous commit
Next Next commit
admendments as suggested by Wes
  • Loading branch information
scbedd authored and azure-sdk committed Jul 17, 2024
commit 81c37ac2298ede489a4d756160df7699c0ec3fe5
30 changes: 24 additions & 6 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,36 @@ function Get-PkgProperties
return $null
}

function Get-PackageFolderFromPath($file) {
$parts = $file -split "/"

if ($parts.Length -lt 3) {
return ""
}
return [System.IO.Path]::Combine($parts[0], $parts[1], $parts[2])
}

# Takes an input diff json file generated from eng/common/scripts/Generate-PR-Diff.ps1
# On PR builds, this function should be utilized instead of Get-AllPkgProperties.
function Get-PrPkgProperties([string]$InputDiffJson) {
$pkgPropsResult = @()
$packagesWithChanges = @()

Write-Host "In Get-PRPkgProperties function"
$allPackageProperties = Get-AllPkgProperties
$diff = Get-Content $InputDiffJson | ConvertFrom-Json
$targetedFiles = $diff.ChangedFiles

if ($GetPRPackageInfoFromRepoFn -and (Test-Path "Function:$GetPRPackageInfoFromRepoFn"))
foreach($pkg in $allPackageProperties)
{
Write-Host "Attempting to invoke the language one"
$pkgPropsResult = &$GetPRPackageInfoFromRepoFn -InputDiffJson $InputDiffJson
foreach($file in $targetedFiles)
{
$pkgFolder = Get-PackageFolderFromPath($file)
if ($pkgFolder.EndsWith($pkg.ArtifactName)) {
$packagesWithChanges += $pkg
}
}
}

return $pkgPropsResult
return $packagesWithChanges
}

# Takes ServiceName and Repo Root Directory
Expand Down