export async function getPRMergeSummary(octokit, owner, repo, pullNumber, baseRef) {
    const [{ data: pull }, protectedBase] = await Promise.all([
        octokit.rest.pulls.get({ owner, repo, pull_number: pullNumber }),
        getProtectedBase(octokit, owner, repo, baseRef),
    ]);
    const mergeStateStatus = typeof pull.mergeable_state === 'string'
        ? pull.mergeable_state
        : undefined;
    return {
        mergeable: pull.mergeable,
        ...(mergeStateStatus && { mergeStateStatus }),
        protectedBase,
    };
}
export async function mergePullRequest(octokit, owner, repo, pullNumber, options) {
    await octokit.rest.pulls.merge({
        owner,
        repo,
        pull_number: pullNumber,
        merge_method: options.method,
        ...(options.expectedHeadSha && { sha: options.expectedHeadSha }),
    });
}
async function getProtectedBase(octokit, owner, repo, branch) {
    try {
        const { data } = await octokit.rest.repos.getBranch({ owner, repo, branch });
        return data.protected;
    }
    catch {
        return null;
    }
}
//# sourceMappingURL=merge.js.map