UNPKG

2.75 kBTypeScriptView Raw
1import { RemoteRepoRef } from "../../operations/common/RepoId";
2import { LocalProject } from "../local/LocalProject";
3import { Configurable } from "./Configurable";
4import { GitStatus } from "./gitStatus";
5/**
6 * Git push options. See git-push(1) for more information.
7 */
8export interface GitPushOptions {
9 follow_tags?: boolean;
10 force?: boolean;
11 force_with_lease?: boolean | string;
12 quiet?: boolean;
13 verbose?: boolean;
14}
15/**
16 * Local project using git. Provides the ability to perform git operations
17 * such as commit, and to set and push to a remote.
18 */
19export interface GitProject extends LocalProject, Configurable {
20 branch: string;
21 remote: string;
22 newRepo: boolean;
23 /**
24 * Init git for this project.
25 */
26 init(): Promise<this>;
27 /**
28 * Get some status information
29 */
30 gitStatus(): Promise<GitStatus>;
31 /**
32 * Remote is of form https://github.com/USERNAME/REPOSITORY.git
33 * @param remote
34 */
35 setRemote(remote: string): Promise<this>;
36 /**
37 * Sets the given user and email as the running git commands
38 * @param {string} user
39 * @param {string} email
40 */
41 setUserConfig(user: string, email: string): Promise<this>;
42 /**
43 * Sets the user config by using GitHub user information. Make sure to use a token that
44 * has user scope.
45 */
46 configureFromRemote(): Promise<this>;
47 /**
48 * Does the project have uncommitted changes in Git? Success means it's clean
49 */
50 isClean(): Promise<boolean>;
51 /**
52 * Create a remote repository and set this repository's remote to it.
53 * @param gid: RemoteRepoRef
54 * @param {string} description
55 * @param {"private" | "public"} visibility
56 */
57 createAndSetRemote(gid: RemoteRepoRef, description: string, visibility: "private" | "public"): Promise<this>;
58 /**
59 * Raise a PR after a push to this branch
60 * @param title
61 * @param body
62 */
63 raisePullRequest(title: string, body: string): Promise<this>;
64 /**
65 * Commit to local git
66 * @param {string} message
67 */
68 commit(message: string): Promise<this>;
69 /**
70 * Check out a particular commit. We'll end in detached head state
71 * @param sha sha or branch identifier
72 */
73 checkout(sha: string): Promise<this>;
74 /**
75 * Revert all changes since last commit
76 */
77 revert(): Promise<this>;
78 /**
79 * Push to the remote.
80 */
81 push(options?: GitPushOptions): Promise<this>;
82 /**
83 * Create a new branch and switch to it.
84 * @param {string} name Name of the new branch
85 */
86 createBranch(name: string): Promise<this>;
87 /**
88 * Check for existence of a branch
89 */
90 hasBranch(name: string): Promise<boolean>;
91}