Skip to content

Commit bd4bd5c

Browse files
committed
chore: add debug logging for open PR checks in getOpenPR method
1 parent 62d4792 commit bd4bd5c

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

src/processor/pull.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,32 +280,47 @@ export class Pull {
280280
}
281281

282282
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+
283287
const res = await this.github.issues.listForRepo({
284288
owner: this.owner,
285289
repo: this.repo,
286290
creator: appConfig.botName,
287291
per_page: 100,
288292
});
289293

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+
);
291298

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+
});
298305

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+
}
307318
}
308319
}
320+
321+
this.logger.debug(
322+
`No open PR found from ${head} to ${base} created by ${appConfig.botName}`,
323+
);
309324
return null;
310325
}
311326

0 commit comments

Comments
 (0)