Skip to content

Commit 1d8f34b

Browse files
committed
filter 3
1 parent 587833c commit 1d8f34b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

.azure-pipelines/PipelineSteps/BatchGeneration/filter.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[CmdletBinding(DefaultParameterSetName="AllSet")]
22
param (
3-
[int]$MaxParallelJobs = 3
3+
[int]$MaxParallelJobs = 3,
4+
[string[]]$ChangedFiles
45
)
56

6-
$base = git merge-base HEAD origin/main
7-
$changedFiles = git diff --name-only $base HEAD
8-
97
$autorestFolders = @{}
108

119
foreach ($file in $changedFiles) {
@@ -19,7 +17,7 @@ foreach ($file in $changedFiles) {
1917
}
2018

2119
$subModules = $autorestFolders.Keys
22-
20+
Write-Host "Outer Group ${subModules}:"
2321

2422
function Split-List {
2523
param (
@@ -61,5 +59,7 @@ foreach ($subModules in $devidedSubModules) {
6159
$index++
6260
}
6361

64-
$MatrixStr=$MatrixStr.Substring(1)
62+
if ($MatrixStr -and $MatrixStr.Length -gt 1) {
63+
$MatrixStr = $MatrixStr.Substring(1)
64+
}
6565
Write-Host "##vso[task.setVariable variable=analyzeTargets;isOutput=true]{$MatrixStr}"

.azure-pipelines/PipelineSteps/BatchGeneration/prepare.ps1

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ foreach ($subModules in $devidedSubModules) {
7777
$index++
7878
}
7979

80-
$MatrixStr=$MatrixStr.Substring(1)
80+
if ($MatrixStr -and $MatrixStr.Length -gt 1) {
81+
$MatrixStr = $MatrixStr.Substring(1)
82+
}
8183
Write-Host "##vso[task.setVariable variable=buildTargets;isOutput=true]{$MatrixStr}"

.azure-pipelines/batch-generation.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,14 @@ jobs:
165165
git commit -m "Apply matrix job patches to ${{ variables.GenerationBranch }}"
166166
git push origin "${{ variables.GenerationBranch }}"
167167
168+
$base = git merge-base HEAD origin/main
169+
$changedFiles = git diff --name-only $base HEAD
170+
168171
$sourceBranchName = "$(Build.SourceBranch)".Replace('refs/heads/', '')
169172
git checkout $sourceBranchName
170173
171174
$filterModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'filter.ps1'
172-
& $filterModulesPath -MaxParallelJobs "${{ variables.MaxParalleAnalyzeJobs }}"
175+
& $filterModulesPath -MaxParallelJobs "${{ variables.MaxParalleAnalyzeJobs }}" -ChangedFiles $changedFiles
173176
# -RepoRoot "$(Build.SourcesDirectory)" -MaxParallelJobs "${{ variables.MaxParalleBuildJobs }}"
174177
175178
# - checkout: none

0 commit comments

Comments
 (0)