UNPKG

5.82 kBTypeScriptView Raw
1import Octokit from '@octokit/rest';
2import { ICommit } from 'gitlog';
3import HttpsProxyAgent from 'https-proxy-agent';
4import { ILabelDefinition } from './release';
5import { ILogger } from './utils/logger';
6declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & Partial<Pick<T, K>>;
7export declare type IPRInfo = Omit<Octokit.ReposCreateStatusParams, 'owner' | 'repo'>;
8export interface IGitOptions {
9 /** Github repo owner (user) */
10 owner: string;
11 /** GitHub project to operate on */
12 repo: string;
13 /** The URL to the GitHub (public or enterprise) the project is using */
14 baseUrl?: string;
15 /** The URL to the GitHub graphql API (public or enterprise) the project is using */
16 graphqlBaseUrl?: string;
17 /** A token to auth to GitHub with */
18 token?: string;
19 /** An optional proxy agent to route requests through */
20 agent?: HttpsProxyAgent;
21}
22/**
23 * A class to interact with the local git instance and the git remote.
24 * currently it only interfaces with GitHub.
25 */
26export default class Git {
27 /** An octokit instance to use to interact with GitHub */
28 readonly github: Octokit;
29 /** Options the git client was initialized with */
30 readonly options: IGitOptions;
31 /** The GitHub api to communicate with through octokit */
32 private readonly baseUrl;
33 /** The GitHub graphql api to communicate with through octokit */
34 private readonly graphqlBaseUrl;
35 /** A logger that uses log levels */
36 private readonly logger;
37 /** Initialize the git interface and auth with GitHub */
38 constructor(options: IGitOptions, logger?: ILogger);
39 /** Get the "Latest Release" from GitHub */
40 getLatestReleaseInfo(): Promise<Octokit.ReposGetLatestReleaseResponse>;
41 /** Get the "Latest Release" or the first commit SHA as a fallback */
42 getLatestRelease(): Promise<string>;
43 /** Get the date a commit sha was created */
44 getCommitDate(sha: string): Promise<string>;
45 /** Get the first commit for the repo */
46 getFirstCommit(): Promise<string>;
47 /** Get the SHA of the latest commit */
48 getSha(short?: boolean): Promise<string>;
49 /** Get the labels for a PR */
50 getLabels(prNumber: number): Promise<string[]>;
51 /** Get all the information about a PR or issue */
52 getPr(prNumber: number): Promise<Octokit.Response<Octokit.IssuesGetResponse>>;
53 /** Get information about specific commit */
54 getCommit(sha: string): Promise<Octokit.Response<Octokit.ReposGetCommitResponse>>;
55 /** Get the labels for a the project */
56 getProjectLabels(): Promise<string[]>;
57 /** Get the git log for a range of commits */
58 getGitLog(start: string, end?: string): Promise<ICommit[]>;
59 /** Get the GitHub user for an email. Will not work if they do not have their email set to "public". */
60 getUserByEmail(email: string): Promise<{} | undefined>;
61 /** Get the GitHub user for a username */
62 getUserByUsername(username: string): Promise<Octokit.UsersGetByUsernameResponse | undefined>;
63 /** Get all the information about a PR or issue */
64 getPullRequest(pr: number): Promise<Octokit.Response<Octokit.PullsGetResponse>>;
65 /** Search to GitHub project's issue and pull requests */
66 searchRepo(options: Octokit.SearchIssuesAndPullRequestsParams): Promise<Octokit.SearchIssuesAndPullRequestsResponse>;
67 /** Run a graphql query on the GitHub project */
68 graphql(query: string): Promise<import("@octokit/graphql/dist-types/types").GraphQlQueryResponseData>;
69 /** Create a status (or checkmark) on a commit */
70 createStatus(prInfo: IPRInfo): Promise<Octokit.Response<Octokit.ReposCreateStatusResponse>>;
71 /** Add a label to the project */
72 createLabel(label: ILabelDefinition): Promise<Octokit.Response<Octokit.IssuesCreateLabelResponse>>;
73 /** Update a label on the project */
74 updateLabel(label: ILabelDefinition): Promise<Octokit.Response<Octokit.IssuesUpdateLabelResponse>>;
75 /** Add a label to and issue or pull request */
76 addLabelToPr(pr: number, label: string): Promise<Octokit.Response<Octokit.IssuesAddLabelsResponse>>;
77 /** Add a label to and issue or pull request */
78 removeLabel(pr: number, label: string): Promise<Octokit.Response<Octokit.IssuesRemoveLabelResponse>>;
79 /** Lock an issue */
80 lockIssue(issue: number): Promise<Octokit.AnyResponse>;
81 /** Get information about the GitHub project */
82 getProject(): Promise<Octokit.ReposGetResponse>;
83 /** Get all the pull requests for a project */
84 getPullRequests(options?: Partial<Octokit.PullsListParams>): Promise<Octokit.PullsListResponse>;
85 /** Get all the commits for a PR */
86 getCommitsForPR(pr: number): Promise<Octokit.PullsListCommitsResponseItem[]>;
87 /** Find a comment that is using the context in a PR */
88 getCommentId(pr: number, context?: string): Promise<number>;
89 /** Delete a comment on an issue or pull request */
90 deleteComment(pr: number, context?: string): Promise<void>;
91 /** Create a comment on an issue or pull request */
92 createComment(message: string, pr: number, context?: string): Promise<Octokit.Response<Octokit.IssuesCreateCommentResponse>>;
93 /** Edit a comment on an issue or pull request */
94 editComment(message: string, pr: number, context?: string): Promise<Octokit.Response<Octokit.IssuesCreateCommentResponse>>;
95 /** Create a comment on a pull request body */
96 addToPrBody(message: string, pr: number, context?: string): Promise<Octokit.Response<Octokit.IssuesUpdateResponse>>;
97 /** Create a release for the GitHub projecct */
98 publish(releaseNotes: string, tag: string, prerelease?: boolean): Promise<Octokit.Response<Octokit.ReposCreateReleaseResponse>>;
99 /** Get the latest tag in the git tree */
100 getLatestTagInBranch(): Promise<string>;
101}
102export {};
103//# sourceMappingURL=git.d.ts.map
\No newline at end of file