UNPKG

@graphql-inspector/cli

Version:

Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.

37 lines (36 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAssociatedPullRequest = exports.getCurrentCommitSha = void 0; const tslib_1 = require("tslib"); const child_process_1 = require("child_process"); const github = tslib_1.__importStar(require("@actions/github")); function getCurrentCommitSha() { const sha = (0, child_process_1.execSync)(`git rev-parse HEAD`).toString().trim(); try { const msg = (0, child_process_1.execSync)(`git show ${sha} -s --format=%s`).toString().trim(); const PR_MSG = /Merge (\w+) into \w+/i; if (PR_MSG.test(msg)) { const result = PR_MSG.exec(msg); if (result) { return result[1]; } } } catch (e) { // } return sha; } exports.getCurrentCommitSha = getCurrentCommitSha; async function getAssociatedPullRequest(octokit, commitSha) { const result = await octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls', { ...github.context.repo, commit_sha: commitSha, mediaType: { format: 'json', previews: ['groot'], }, }); return result.data.length > 0 ? result.data[0] : null; } exports.getAssociatedPullRequest = getAssociatedPullRequest;