From 07d28012b499cc1a5bc9881cda913fb4370ded3c Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:16:53 -0800 Subject: [PATCH] handle only deleted files in a - pullrequest build (#43835) Co-authored-by: Scott Beddall --- eng/common/scripts/Generate-PR-Diff.ps1 | 2 ++ eng/common/scripts/Package-Properties.ps1 | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/eng/common/scripts/Generate-PR-Diff.ps1 b/eng/common/scripts/Generate-PR-Diff.ps1 index e010e176399d2..4e34032c47c89 100644 --- a/eng/common/scripts/Generate-PR-Diff.ps1 +++ b/eng/common/scripts/Generate-PR-Diff.ps1 @@ -48,6 +48,7 @@ $changedFiles = @() $changedServices = @() $changedFiles = Get-ChangedFiles -DiffPath $TargetPath +$deletedFiles = Get-ChangedFiles -DiffPath $TargetPath -DiffFilterType "D" if ($changedFiles) { $changedServices = Get-ChangedServices -ChangedFiles $changedFiles @@ -63,6 +64,7 @@ $result = [PSCustomObject]@{ "ChangedFiles" = $changedFiles "ChangedServices" = $changedServices "ExcludePaths" = $ExcludePaths + "DeletedFiles" = $deletedFiles "PRNumber" = if ($env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER) { $env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER } else { "-1" } } diff --git a/eng/common/scripts/Package-Properties.ps1 b/eng/common/scripts/Package-Properties.ps1 index bc7b5738e2d36..a23ee76bbda6c 100644 --- a/eng/common/scripts/Package-Properties.ps1 +++ b/eng/common/scripts/Package-Properties.ps1 @@ -162,6 +162,14 @@ function Get-PrPkgProperties([string]$InputDiffJson) { $allPackageProperties = Get-AllPkgProperties $diff = Get-Content $InputDiffJson | ConvertFrom-Json $targetedFiles = $diff.ChangedFiles + + if ($diff.DeletedFiles) { + if (-not $targetedFiles) { + $targetedFiles = @() + } + $targetedFiles += $diff.DeletedFiles + } + # The exclude paths and the targeted files paths aren't full OS paths, they're # GitHub paths meaning they're relative to the repo root and slashes are forward # slashes "/". The ExcludePaths need to have a trailing slash added in order