Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion eng/common/scripts/AutoRelease-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function Get-GitHubAutoReleasePullRequestForCommit {
# PullRequestNumber : the PR number recorded in the diff object.
# PullRequestFiles : the file entries returned by Get-GitHubPullRequestFiles.
# ExcludePaths : optional paths to record on the diff object.
# ExcludeServiceRootFiles : excludes files directly under sdk/<service> so they do not resolve every
# package in that service.
#
# Returns a PSCustomObject with ChangedFiles, ChangedServices, ExcludePaths, DeletedFiles, PRNumber.
function New-GitHubPullRequestDiffObject {
Expand All @@ -97,7 +99,8 @@ function New-GitHubPullRequestDiffObject {
[AllowEmptyCollection()]
[array] $PullRequestFiles,
[AllowEmptyCollection()]
[array] $ExcludePaths = @()
[array] $ExcludePaths = @(),
[switch] $ExcludeServiceRootFiles
)

$changedFiles = @()
Expand All @@ -119,6 +122,12 @@ function New-GitHubPullRequestDiffObject {
}
}

if ($ExcludeServiceRootFiles) {
$serviceRootFilePattern = '^sdk/[^/]+/[^/]+$'
$changedFiles = @($changedFiles | Where-Object { $_ -notmatch $serviceRootFilePattern })
$deletedFiles = @($deletedFiles | Where-Object { $_ -notmatch $serviceRootFilePattern })
Comment thread
raych1 marked this conversation as resolved.
}
Comment thread
raych1 marked this conversation as resolved.

$changedFiles = @($changedFiles | Where-Object { $_ } | Sort-Object -Unique)
$deletedFiles = @($deletedFiles | Where-Object { $_ } | Sort-Object -Unique)

Expand Down
10 changes: 7 additions & 3 deletions eng/common/scripts/Resolve-AutoReleasePackages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ commit, this script:
'auto-release' label.
2. Builds a PR diff object (New-GitHubPullRequestDiffObject) from the PR's changed files and reuses
the repo's existing package-detection logic (Get-PrPkgProperties) to identify the changed packages
(honoring triggering paths, deleted files and service-level changes), excluding
validation-only packages. Get-PrPkgProperties delegates to each repo's own
(honoring triggering paths and deleted files while ignoring only files directly under
sdk/<service>/, not files in package subdirectories), excluding validation-only packages.
Get-PrPkgProperties delegates to each repo's own
Get-AllPackageInfoFromRepo (language-settings.ps1), so this script works for any language repo.
3. Intersects those packages with this pipeline's declared artifacts and emits Azure DevOps output
variables consumed by the release stages. Both consumption styles are emitted:
Expand Down Expand Up @@ -135,7 +136,10 @@ function Invoke-AutoReleaseResolution {
# package-detection logic to identify the changed packages.
Write-Host "Fetching changed files for PR $prLink..."
$files = @(Get-GitHubPullRequestFiles -RepoId $RepoId -PullRequestNumber $pr.number -AuthToken $AuthToken)
$diff = New-GitHubPullRequestDiffObject -PullRequestNumber $pr.number -PullRequestFiles $files
$diff = New-GitHubPullRequestDiffObject `
-PullRequestNumber $pr.number `
-PullRequestFiles $files `
-ExcludeServiceRootFiles
Write-Host "PR $prLink changed $($diff.ChangedFiles.Count) file(s) and deleted $($diff.DeletedFiles.Count) file(s)."

$diffPath = Join-Path ([System.IO.Path]::GetTempPath()) ("autorelease-diff-" + [System.Guid]::NewGuid().ToString('N') + ".json")
Expand Down
Loading