@@ -280,32 +280,47 @@ export class Pull {
280
280
}
281
281
282
282
private async getOpenPR ( base : string , head : string ) {
283
+ this . logger . debug (
284
+ `Checking for open PRs from ${ head } to ${ base } created by ${ appConfig . botName } ` ,
285
+ ) ;
286
+
283
287
const res = await this . github . issues . listForRepo ( {
284
288
owner : this . owner ,
285
289
repo : this . repo ,
286
290
creator : appConfig . botName ,
287
291
per_page : 100 ,
288
292
} ) ;
289
293
290
- if ( res . data . length === 0 ) return null ;
294
+ if ( res . data . length > 0 ) {
295
+ this . logger . debug (
296
+ `Found ${ res . data . length } open ${ pluralize ( "PR" , res . data . length , true ) } from ${ appConfig . botName } ` ,
297
+ ) ;
291
298
292
- for ( const issue of res . data ) {
293
- const pr = await this . github . pulls . get ( {
294
- owner : this . owner ,
295
- repo : this . repo ,
296
- pull_number : issue . number ,
297
- } ) ;
299
+ for ( const issue of res . data ) {
300
+ const pr = await this . github . pulls . get ( {
301
+ owner : this . owner ,
302
+ repo : this . repo ,
303
+ pull_number : issue . number ,
304
+ } ) ;
298
305
299
- if (
300
- pr . data . user . login === appConfig . botName &&
301
- pr . data . base . label . replace ( `${ this . owner } :` , "" ) ===
302
- base . replace ( `${ this . owner } :` , "" ) &&
303
- pr . data . head . label . replace ( `${ this . owner } :` , "" ) ===
304
- head . replace ( `${ this . owner } :` , "" )
305
- ) {
306
- return pr . data ;
306
+ if (
307
+ pr . data . user . login === appConfig . botName &&
308
+ pr . data . base . label . replace ( `${ this . owner } :` , "" ) ===
309
+ base . replace ( `${ this . owner } :` , "" ) &&
310
+ pr . data . head . label . replace ( `${ this . owner } :` , "" ) ===
311
+ head . replace ( `${ this . owner } :` , "" )
312
+ ) {
313
+ this . logger . debug (
314
+ `Found open PR #${ pr . data . number } from ${ head } to ${ base } created by ${ appConfig . botName } ` ,
315
+ ) ;
316
+ return pr . data ;
317
+ }
307
318
}
308
319
}
320
+
321
+ this . logger . debug (
322
+ `No open PR found from ${ head } to ${ base } created by ${ appConfig . botName } ` ,
323
+ ) ;
309
324
return null ;
310
325
}
311
326
0 commit comments