UNPKG

code-suggester

Version:
57 lines (56 loc) 3.97 kB
import { Changes, CreatePullRequestUserOptions, FileDiffContent, CreateReviewCommentUserOptions } from './types'; export { Changes, CommitData, CommitSigner } from './types'; import { Octokit } from '@octokit/rest'; export { getChanges, getDiffString } from './bin/handle-git-dir-change'; export { CommitError } from './errors'; /** * Given a set of suggestions, make all the multiline inline review comments on a given pull request given * that they are in scope of the pull request. Outof scope suggestions are not made. * * In-scope suggestions are specifically: the suggestion for a file must correspond to a file in the remote pull request * and the diff hunk computed for a file's contents must produce a range that is a subset of the pull request's files hunks. * * If a file is too large to load in the review, it is skipped in the suggestion phase. * * If changes are empty then the workflow will not run. * Rethrows an HttpError if Octokit GitHub API returns an error. HttpError Octokit access_token and client_secret headers redact all sensitive information. * @param octokit The authenticated octokit instance, instantiated with an access token having permissiong to create a fork on the target repository. * @param diffContents A set of changes. The changes may be empty. * @param options The configuration for interacting with GitHub provided by the user. * @returns the created review's id number, or null if there are no changes to be made. */ export declare function reviewPullRequest(octokit: Octokit, diffContents: Map<string, FileDiffContent> | string, options: CreateReviewCommentUserOptions): Promise<number | null>; /** * Make a new GitHub Pull Request with a set of changes applied on top of primary branch HEAD. * The changes are committed into a new branch based on the upstream repository options using the authenticated Octokit account. * Then a Pull Request is made from that branch. * * Also throws error if git data from the fork is not ready in 5 minutes. * * From the docs * https://developer.github.com/v3/repos/forks/#create-a-fork * """ * Forking a Repository happens asynchronously. * You may have to wait a short period of time before you can access the git objects. * If this takes longer than 5 minutes, be sure to contact GitHub Support or GitHub Premium Support. * """ * * If changes are empty then the workflow will not run. * Rethrows an HttpError if Octokit GitHub API returns an error. HttpError Octokit access_token and client_secret headers redact all sensitive information. * @param {Octokit} octokit The authenticated octokit instance, instantiated with an access token having permissiong to create a fork on the target repository * @param {Changes | null | undefined} changes A set of changes. The changes may be empty * @param {CreatePullRequestUserOptions} options The configuration for interacting with GitHub provided by the user. * @returns {Promise<number>} the pull request number. Returns 0 if unsuccessful. * @throws {CommitError} on failure during commit process */ declare function createPullRequest(octokit: Octokit, changes: Changes | null | undefined, options: CreatePullRequestUserOptions): Promise<number>; /** * Convert a Map<string,string> or {[path: string]: string}, where the key is the relative file path in the repository, * and the value is the text content. The files will be converted to a Map also containing the file mode information '100644' * @param {Object<string, string | null> | Map<string, string | null>} textFiles a map/object where the key is the relative file path and the value is the text file content * @returns {Changes} Map of the file path to the string file content and the file mode '100644' */ declare function parseTextFiles(textFiles: { [path: string]: string | null; } | Map<string, string | null>): Changes; export { createPullRequest, parseTextFiles, CreateReviewCommentUserOptions, CreatePullRequestUserOptions, };