UNPKG

backport

Version:

A CLI tool that automates the process of backporting commits

32 lines 1.17 kB
import { graphql } from '../../../graphql/generated/index.js'; import { BackportError } from '../../backport-error.js'; import { graphqlRequest } from './client/graphql-client.js'; export async function fetchPullRequestId(options, pullNumber) { const { githubToken, githubApiBaseUrlV4, repoName, repoOwner } = options; const query = graphql(` query PullRequestId($repoOwner: String!, $repoName: String!, $pr: Int!) { repository(owner: $repoOwner, name: $repoName) { pullRequest(number: $pr) { id } } } `); const variables = { repoOwner, repoName, pr: pullNumber }; const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables); if (result.error) { throw new BackportError({ code: 'github-api-exception', message: result.error.message, }); } const pullRequestId = result.data?.repository?.pullRequest?.id; if (!pullRequestId) { throw new BackportError({ code: 'pr-not-found-exception', pullNumber, }); } return pullRequestId; } //# sourceMappingURL=fetch-pull-request-id.js.map