MCPcopy Create free account
hub / github.com/decaporg/decap-cms / getPullRequests

Method getPullRequests

packages/decap-cms-backend-forgejo/src/API.ts:574–607  ·  view source on GitHub ↗
(
    state: 'open' | 'closed' | 'all' = 'open',
    head?: string,
  )

Source from the content-addressed store, hash-verified

572 }
573
574 async getPullRequests(
575 state: 'open' | 'closed' | 'all' = 'open',
576 head?: string,
577 ): Promise<ForgejoPullRequest[]> {
578 const pullRequests = await this.requestAllPages<ForgejoPullRequest>(
579 `${this.originRepoURL}/pulls`,
580 {
581 params: { state, base: this.branch, limit: 100 },
582 },
583 );
584 if (!head) {
585 return pullRequests;
586 }
587
588 return pullRequests.filter(pr => {
589 const label = pr.head?.label;
590 const repoOwner = pr.head?.repo?.owner?.login;
591 const ref = pr.head?.ref;
592
593 if (label === head) {
594 return true;
595 }
596 if (repoOwner && ref) {
597 return `${repoOwner}:${ref}` === head;
598 }
599
600 // Forgejo may return a branch-only label for same-repository PRs.
601 if (ref) {
602 return `${this.repoOwner}:${ref}` === head;
603 }
604
605 return false;
606 });
607 }
608
609 async getOpenAuthoringPullRequest(
610 branch: string,

Callers 4

getBranchPullRequestMethod · 0.95
API.spec.jsFile · 0.45

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected