Package code-suggester (4.3.3)

Classes

CommitError

Interfaces

CommitData

CommitSigner

CreatePullRequestUserOptions

The user options for creating GitHub PRs

CreateReviewCommentUserOptions

The user options for creating GitHub PR review comment

Functions

createPullRequest(octokit, changes, options)

declare function createPullRequest(octokit: Octokit, changes: Changes | null | undefined, options: CreatePullRequestUserOptions): Promise

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.

Parameters
NameDescription
octokitOctokit

The authenticated octokit instance, instantiated with an access token having permissiong to create a fork on the target repository

changesChanges | null | undefined

A set of changes. The changes may be empty

optionsCreatePullRequestUserOptions

The configuration for interacting with GitHub provided by the user.

Returns
TypeDescription
Promise<number>

{Promise

getChanges(dir)

export declare function getChanges(dir: string): Promise

Load the change set asynchronously.

Parameter
NameDescription
dirstring

the directory containing git changes

Returns
TypeDescription
Promise<Changes>

{Promise

getDiffString(dir)

export declare function getDiffString(dir: string): string;

Get the git changes of the current project asynchronously. Rejects if any of the files fails to load (if not deleted), or if there is a git diff parse error

Parameter
NameDescription
dirstring
Returns
TypeDescription
string

{string} the diff

parseTextFiles(textFiles)

declare function parseTextFiles(textFiles: {
    [path: string]: string | null;
} | Map

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'

Parameter
NameDescription
textFiles{ [path: string]: string | null; } | Map<string, string | null>

a map/object where the key is the relative file path and the value is the text file content

Returns
TypeDescription
Changes

{Changes} Map of the file path to the string file content and the file mode '100644'

reviewPullRequest(octokit, diffContents, options)

export declare function reviewPullRequest(octokit: Octokit, diffContents: Map

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.

Parameters
NameDescription
octokitOctokit

The authenticated octokit instance, instantiated with an access token having permissiong to create a fork on the target repository.

diffContentsMap<string, FileDiffContent> | string

A set of changes. The changes may be empty.

optionsCreateReviewCommentUserOptions

The configuration for interacting with GitHub provided by the user.

Returns
TypeDescription
Promise<number | null>

the created review's id number, or null if there are no changes to be made.

Type Aliases

Changes

export declare type Changes = Map

The map of a path to its content data. The content must be the entire file content.