UNPKG

backport

Version:

A CLI tool that automates the process of backporting commits

34 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchPullRequestId = void 0; const generated_1 = require("../../../graphql/generated"); const graphqlClient_1 = require("./client/graphqlClient"); async function fetchPullRequestId(options, pullNumber) { const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options; const query = (0, generated_1.graphql)(` query PullRequestId( $repoOwner: String! $repoName: String! $pullNumber: Int! ) { repository(owner: $repoOwner, name: $repoName) { pullRequest(number: $pullNumber) { id } } } `); const variables = { repoOwner, repoName, pullNumber }; const client = (0, graphqlClient_1.getGraphQLClient)({ accessToken, githubApiBaseUrlV4 }); const result = await client.query(query, variables); if (result.error) { throw new graphqlClient_1.GithubV4Exception(result); } const pullRequestId = result.data?.repository?.pullRequest?.id; if (!pullRequestId) { throw new Error(`No pull request found with number "${pullNumber}"`); } return pullRequestId; } exports.fetchPullRequestId = fetchPullRequestId; //# sourceMappingURL=fetchPullRequestId2.js.map