@@ -80,22 +80,13 @@ function Submit-Request($filePath, $packageName)
80
80
return $StatusCode
81
81
}
82
82
83
- function Should-Process-Package ($pkgPath , $packageName )
83
+ function Should-Process-Package ($packageInfo )
84
84
{
85
- $pkg = Split-Path - Leaf $pkgPath
86
- $pkgPropPath = Join-Path - Path $configFileDir " $packageName .json"
87
- if (! (Test-Path $pkgPropPath ))
88
- {
89
- LogWarning " Package property file path $ ( $pkgPropPath ) is invalid."
90
- return $False
91
- }
92
- # Get package info from json file created before updating version to daily dev
93
- $pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json
94
- $packagePath = $pkgInfo.DirectoryPath
85
+ $packagePath = $packageInfo.DirectoryPath
95
86
$modifiedFiles = @ (Get-ChangedFiles - DiffPath " $packagePath /*" - DiffFilterType ' ' )
96
87
$filteredFileCount = $modifiedFiles.Count
97
88
LogInfo " Number of modified files for package: $filteredFileCount "
98
- return ($filteredFileCount -gt 0 -and $pkgInfo .IsNewSdk )
89
+ return ($filteredFileCount -gt 0 -and $packageInfo .IsNewSdk )
99
90
}
100
91
101
92
function Log-Input-Params ()
@@ -126,24 +117,42 @@ $responses = @{}
126
117
127
118
LogInfo " Processing PackageInfo at $configFileDir "
128
119
129
- $packageProperties = Get-ChildItem - Recurse - Force " $configFileDir " `
130
- | Where-Object {
120
+ $packageInfoFiles = Get-ChildItem - Recurse - Force " $configFileDir " `
121
+ | Where-Object {
131
122
$_.Extension -eq ' .json' -and ($_.FullName.Substring ($configFileDir.Length + 1 ) -notmatch ' ^_.*?[\\\/]' )
132
123
}
133
124
134
- foreach ($packagePropFile in $packageProperties )
125
+ foreach ($packageInfoFile in $packageInfoFiles )
135
126
{
136
- $packageMetadata = Get-Content $packagePropFile | ConvertFrom-Json
137
- $pkgArtifactName = $packageMetadata .ArtifactName ?? $packageMetadata .Name
127
+ $packageInfo = Get-Content $packageInfoFile | ConvertFrom-Json
128
+ $pkgArtifactName = $packageInfo .ArtifactName ?? $packageInfo .Name
138
129
139
130
LogInfo " Processing $ ( $pkgArtifactName ) "
140
131
141
- $packages = & $FindArtifactForApiReviewFn $ArtifactPath $pkgArtifactName
132
+ # Check if the function supports the packageInfo parameter
133
+ $functionInfo = Get-Command $FindArtifactForApiReviewFn - ErrorAction SilentlyContinue
134
+ $supportsPackageInfoParam = $false
135
+
136
+ if ($functionInfo -and $functionInfo.Parameters ) {
137
+ # Check if function specifically supports packageInfo parameter
138
+ $parameterNames = $functionInfo.Parameters.Keys
139
+ $supportsPackageInfoParam = $parameterNames -contains ' packageInfo'
140
+ }
141
+
142
+ # Call function with appropriate parameters
143
+ if ($supportsPackageInfoParam ) {
144
+ LogInfo " Calling $FindArtifactForApiReviewFn with packageInfo parameter"
145
+ $packages = & $FindArtifactForApiReviewFn $ArtifactPath $pkgArtifactName $packageInfo
146
+ }
147
+ else {
148
+ LogInfo " Calling $FindArtifactForApiReviewFn with legacy parameters"
149
+ $packages = & $FindArtifactForApiReviewFn $ArtifactPath $pkgArtifactName
150
+ }
142
151
143
152
if ($packages )
144
153
{
145
154
$pkgPath = $packages.Values [0 ]
146
- $isRequired = Should- Process- Package - pkgPath $pkgPath - packageName $pkgArtifactName
155
+ $isRequired = Should- Process- Package $packageInfo
147
156
LogInfo " Is API change detect required for $ ( $pkgArtifactName ) :$ ( $isRequired ) "
148
157
if ($isRequired -eq $True )
149
158
{
@@ -156,7 +165,7 @@ foreach ($packagePropFile in $packageProperties)
156
165
}
157
166
else
158
167
{
159
- LogInfo " Pull request does not have any change for $ ( $pkgArtifactName ) ) . Skipping API change detect."
168
+ LogInfo " Pull request does not have any change for $ ( $pkgArtifactName ) . Skipping API change detect."
160
169
}
161
170
}
162
171
else
0 commit comments