MCPcopy Index your code
hub / github.com/wei/pull / getOpenPR

Method getOpenPR

src/processor/pull.ts:282–325  ·  view source on GitHub ↗
(base: string, head: string)

Source from the content-addressed store, hash-verified

280 }
281
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
287 const res = await this.github.issues.listForRepo({
288 owner: this.owner,
289 repo: this.repo,
290 creator: appConfig.botName,
291 per_page: 100,
292 });
293
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 );
298
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 });
305
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 }
318 }
319 }
320
321 this.logger.debug(
322 `No open PR found from ${head} to ${base} created by ${appConfig.botName}`,
323 );
324 return null;
325 }
326
327 private async createPR(
328 base: string,

Callers 1

routineCheckMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected