@@ -55,7 +55,7 @@ function GetOwnersWithModifiedFiles(
5555 if ( ! regex_match ) {
5656 let regex = ownerPath
5757 //No slashes at all, match any file at any level
58- const fileMode = regex . includes ( '/' )
58+ const fileMode = ! regex . includes ( '/' )
5959 //Remove leading slash before generating Regex as modified files from PR don't start with slash aka src/code/Program.cs and not /src...
6060 regex = regex . replace ( '/' , '' )
6161
@@ -167,56 +167,22 @@ async function run(): Promise<void> {
167167 return
168168 }
169169
170- //Remove users that have previously removed/added themself to review
171- ; (
172- await octokit . paginate <
173- RestEndpointMethodTypes [ 'issues' ] [ 'listEvents' ] [ 'response' ] [ 'data' ]
174- > (
175- octokit . rest . issues . listEvents . endpoint . merge ( {
176- owner : core_owner ,
177- repo : core_repo ,
178- issue_number : pull_number
179- } )
180- )
181- )
182- . flatMap ( array => array )
183- . reverse ( ) //reverse to get latest events
184- . forEach ( issue_event => {
185- const event = issue_event . event
186- if (
187- event == 'review_request_removed' ||
188- event == 'review_requested'
189- ) {
190- const remove = issue_event . actor . login
191-
192- //skip bot events
193- if ( remove == 'github-actions[bot]' ) {
194- return
195- }
196-
197- //if user has triggered this event then we skip it
198- const index = trimmed_owners . indexOf ( remove )
199- if ( index >= 0 ) {
200- notice (
201- `User ${ remove } has ${ event == 'review_request_removed' ? 'previously removed' : 'already added' } themself as a reviewer.`
202- )
203- trimmed_owners . splice ( index , 1 )
204- }
205- }
206- } )
207-
208170 //Remove Invalid users
209171 for ( const user of trimmed_owners . toReversed ( ) ) {
210- const response : RestEndpointMethodTypes [ 'issues' ] [ 'checkUserCanBeAssigned' ] [ 'response' ] =
211- await octokit . rest . issues . checkUserCanBeAssigned ( {
212- owner : core_owner ,
213- repo : core_repo ,
214- assignee : user
215- } )
216- if ( response . status != 204 ) {
217- notice (
218- `User ${ user } cannot be requested for review, make sure they are a member of a team with read access.`
219- )
172+ try {
173+ const response : RestEndpointMethodTypes [ 'issues' ] [ 'checkUserCanBeAssigned' ] [ 'response' ] =
174+ await octokit . rest . issues . checkUserCanBeAssigned ( {
175+ owner : core_owner ,
176+ repo : core_repo ,
177+ assignee : user
178+ } )
179+ if ( response . status != 204 ) {
180+ throw new Error (
181+ `Cannot be requested for review, make sure they are a member of a team with read access.`
182+ )
183+ }
184+ } catch ( ex ) {
185+ notice ( `Error verifying user ${ user } : ${ ex } ` )
220186 trimmed_owners . splice ( trimmed_owners . indexOf ( user ) , 1 )
221187 }
222188 }
0 commit comments