|
1 | 1 | /* tslint:disable */
|
2 | 2 | /* eslint-disable */
|
3 | 3 |
|
4 |
| -/* auto-generated by NAPI-RS */ |
| 4 | +import { RepositoryState } from './es-git'; |
5 | 5 |
|
6 |
| -export interface Branch { |
7 |
| - name: string |
8 |
| - oid: string |
9 |
| -} |
10 |
| -export interface CreateBranchOptions { |
11 |
| - branchName: string |
12 |
| - targetSha: string |
13 |
| - force?: boolean |
14 |
| -} |
15 |
| -export interface GetBranchOptions { |
16 |
| - branchName: string |
17 |
| -} |
18 |
| -export interface DeleteBranchOptions { |
19 |
| - branchName: string |
20 |
| -} |
21 |
| -export declare function createBranch(options: CreateBranchOptions, context: GitContext): Branch |
22 |
| -export declare function getBranch(options: GetBranchOptions, context: GitContext): Branch |
23 |
| -export declare function deleteBranch(options: DeleteBranchOptions, context: GitContext): void |
24 |
| -export interface GitContext { |
25 |
| - dir: string |
26 |
| -} |
27 |
| -export declare function removeRef(gitRef: string, context: GitContext): void |
28 |
| -export declare function getRemoteUrl(name: string, context: GitContext): string | null |
29 |
| -export declare function getSha(gitRef: string, context: GitContext): string |
30 |
| -export declare function getHeadSha(context: GitContext): string |
31 |
| -export declare function getGitRootPath(context: GitContext): string |
32 |
| -export declare function hasMergeConflicts(ref1: string, ref2: string, context: GitContext): boolean |
33 |
| -export interface Conflict { |
34 |
| - ancestor?: string |
35 |
| - our?: string |
36 |
| - their?: string |
37 |
| -} |
38 |
| -export declare function getConflictingFiles(ref1: string, ref2: string, context: GitContext): Array<Conflict> |
39 |
| -export interface CreateTagOptions { |
40 |
| - name: string |
41 |
| - message: string |
42 |
| - sha: string |
43 |
| -} |
44 |
| -export interface CreateTagResult { |
45 |
| - oid: string |
46 |
| -} |
47 |
| -export declare function createTag(options: CreateTagOptions, context: GitContext): CreateTagResult |
48 |
| -export declare function deleteTag(name: string, context: GitContext): void |
| 6 | +/** |
| 7 | + * TODO: |
| 8 | + * napi does not support union types when converting rust enum types to TypeScript. |
| 9 | + * This feature will be provided starting from v3, so create a custom TypeScript until the v3 stable releases. |
| 10 | + */ |
| 11 | + |
| 12 | +export interface RemoteObject { |
| 13 | + name: string; |
| 14 | + url: string; |
| 15 | + pushUrl?: string; |
| 16 | + refspecs: Array<RefspecObject>; |
| 17 | +} |
| 18 | +export const enum Direction { |
| 19 | + Fetch = 'Fetch', |
| 20 | + Push = 'Push' |
| 21 | +} |
| 22 | +export interface RefspecObject { |
| 23 | + direction: Direction; |
| 24 | + src: string; |
| 25 | + dst: string; |
| 26 | + force: boolean; |
| 27 | +} |
| 28 | +export type Credential = |
| 29 | + /** Create a "default" credential usable for Negotiate mechanisms like NTLM or Kerberos authentication. */ |
| 30 | + | { type: 'Default' } |
| 31 | + /** |
| 32 | + * Create a new ssh key credential object used for querying an ssh-agent. |
| 33 | + * The username specified is the username to authenticate. |
| 34 | + */ |
| 35 | + | { type: 'SSHKeyFromAgent'; username?: string } |
| 36 | + /** Create a new passphrase-protected ssh key credential object. */ |
| 37 | + | { type: 'SSHKeyFromPath'; username?: string; publicKeyPath?: string; privateKeyPath: string; passphrase?: string } |
| 38 | + /** Create a new ssh key credential object reading the keys from memory. */ |
| 39 | + | { type: 'SSHKey'; username?: string; publicKey?: string; privateKey: string; passphrase?: string } |
| 40 | + /** Create a new plain-text username and password credential object. */ |
| 41 | + | { type: 'Plain'; username?: string; password: string }; |
| 42 | +/** Options which can be specified to various fetch operations. */ |
| 43 | +export interface ProxyOptions { |
| 44 | + /** |
| 45 | + * Try to auto-detect the proxy from the git configuration. |
| 46 | + * |
| 47 | + * Note that this will override `url` specified before. |
| 48 | + */ |
| 49 | + auto?: boolean |
| 50 | + /** |
| 51 | + * Specify the exact URL of the proxy to use. |
| 52 | + * |
| 53 | + * Note that this will override `auto` specified before. |
| 54 | + */ |
| 55 | + url?: string |
| 56 | +} |
| 57 | +export type FetchPrune = |
| 58 | + /** Use the setting from the configuration */ |
| 59 | + | 'Unspecified' |
| 60 | + /** Force pruning on */ |
| 61 | + | 'On' |
| 62 | + /** Force pruning off */ |
| 63 | + | 'Off'; |
| 64 | +/** Automatic tag following options. */ |
| 65 | +export type AutotagOption = |
| 66 | + /** Use the setting from the remote's configuration */ |
| 67 | + | 'Unspecified' |
| 68 | + /** Ask the server for tags pointing to objects we're already downloading */ |
| 69 | + | 'Auto' |
| 70 | + /** Don't ask for any tags beyond the refspecs */ |
| 71 | + | 'None' |
| 72 | + /** Ask for all the tags */ |
| 73 | + | 'All'; |
| 74 | +/** |
| 75 | + * Remote redirection settings; whether redirects to another host are |
| 76 | + * permitted. |
| 77 | + * |
| 78 | + * By default, git will follow a redirect on the initial request |
| 79 | + * (`/info/refs`), but not subsequent requests. |
| 80 | + */ |
| 81 | +export type RemoteRedirect = |
| 82 | + /** Do not follow any off-site redirects at any stage of the fetch or push. */ |
| 83 | + | 'None' |
| 84 | + /** |
| 85 | + * Allow off-site redirects only upon the initial request. This is the |
| 86 | + * default. |
| 87 | + */ |
| 88 | + | 'Initial' |
| 89 | + /** Allow redirects at any stage in the fetch or push. */ |
| 90 | + | 'All'; |
| 91 | +/** Options which can be specified to various fetch operations. */ |
| 92 | +export interface FetchOptions { |
| 93 | + credential?: Credential; |
| 94 | + /** Set the proxy options to use for the fetch operation. */ |
| 95 | + proxy?: ProxyOptions; |
| 96 | + /** Set whether to perform a prune after the fetch. */ |
| 97 | + prune?: FetchPrune; |
| 98 | + /** |
| 99 | + * Set fetch depth, a value less or equal to 0 is interpreted as pull |
| 100 | + * everything (effectively the same as not declaring a limit depth). |
| 101 | + */ |
| 102 | + depth?: number; |
| 103 | + /** |
| 104 | + * Set how to behave regarding tags on the remote, such as auto-downloading |
| 105 | + * tags for objects we're downloading or downloading all of them. |
| 106 | + * |
| 107 | + * The default is to auto-follow tags. |
| 108 | + */ |
| 109 | + downloadTags?: AutotagOption; |
| 110 | + /** |
| 111 | + * Set remote redirection settings; whether redirects to another host are |
| 112 | + * permitted. |
| 113 | + * |
| 114 | + * By default, git will follow a redirect on the initial request |
| 115 | + * (`/info/refs`), but not subsequent requests. |
| 116 | + */ |
| 117 | + followRedirects?: RemoteRedirect; |
| 118 | + /** Set extra headers for this fetch operation. */ |
| 119 | + customHeaders?: Array<string>; |
| 120 | +} |
| 121 | +/** Options to control the behavior of a git push. */ |
| 122 | +export interface PushOptions { |
| 123 | + credential?: Credential; |
| 124 | + /** Set the proxy options to use for the push operation. */ |
| 125 | + proxy?: ProxyOptions; |
| 126 | + /** |
| 127 | + * If the transport being used to push to the remote requires the creation |
| 128 | + * of a pack file, this controls the number of worker threads used by the |
| 129 | + * packbuilder when creating that pack file to be sent to the remote. |
| 130 | + * |
| 131 | + * if set to 0 the packbuilder will auto-detect the number of threads to |
| 132 | + * create, and the default value is 1. |
| 133 | + */ |
| 134 | + pbParallelism?: number; |
| 135 | + /** |
| 136 | + * Set remote redirection settings; whether redirects to another host are |
| 137 | + * permitted. |
| 138 | + * |
| 139 | + * By default, git will follow a redirect on the initial request |
| 140 | + * (`/info/refs`), but not subsequent requests. |
| 141 | + */ |
| 142 | + followRedirects?: RemoteRedirect; |
| 143 | + /** Set extra headers for this push operation. */ |
| 144 | + customHeaders?: Array<string>; |
| 145 | + /** Set "push options" to deliver to the remote. */ |
| 146 | + remoteOptions?: Array<string>; |
| 147 | +} |
| 148 | +export interface CreateRemoteOptions { |
| 149 | + fetchRefspec?: string; |
| 150 | +} |
| 151 | +export interface FetchRemoteOptions { |
| 152 | + fetch?: FetchOptions; |
| 153 | + reflogMsg?: string; |
| 154 | +} |
| 155 | +export interface PruneOptions { |
| 156 | + credential?: Credential; |
| 157 | +} |
| 158 | +export type RepositoryState = |
| 159 | + | 'Clean' |
| 160 | + | 'Merge' |
| 161 | + | 'Revert' |
| 162 | + | 'RevertSequence' |
| 163 | + | 'CherryPick' |
| 164 | + | 'CherryPickSequence' |
| 165 | + | 'Bisect' |
| 166 | + | 'Rebase' |
| 167 | + | 'RebaseInteractive' |
| 168 | + | 'RebaseMerge' |
| 169 | + | 'ApplyMailbox' |
| 170 | + | 'ApplyMailboxOrRebase'; |
| 171 | +export interface RepositoryInitOptions { |
| 172 | + bare?: boolean; |
| 173 | + initialHead?: string; |
| 174 | + originUrl?: string; |
| 175 | +} |
| 176 | +export interface RepositoryOpenOptions { |
| 177 | + flags: RepositoryOpenFlags; |
| 178 | + ceilingDirs?: Array<string>; |
| 179 | +} |
| 180 | +export type RepositoryOpenFlags = |
| 181 | +/** Only open the specified path; don't walk upward searching. */ |
| 182 | + | 'NoSearch' |
| 183 | + /** Search across filesystem boundaries. */ |
| 184 | + | 'CrossFS' |
| 185 | + /** Force opening as bare repository, and defer loading its config. */ |
| 186 | + | 'Bare' |
| 187 | + /** Don't try appending `/.git` to the specified repository path. */ |
| 188 | + | 'NoDotGit' |
| 189 | + /** Respect environment variables like `$GIT_DIR`. */ |
| 190 | + | 'FromEnv'; |
| 191 | +export interface RepositoryCloneOptions { |
| 192 | + recursive?: boolean; |
| 193 | + fetch?: FetchOptions; |
| 194 | +} |
| 195 | + |
| 196 | +export declare function initRepository(path: string, options?: RepositoryInitOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository> |
| 197 | +export declare function openRepository(path: string, options?: RepositoryOpenOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository> |
| 198 | +export declare function discoverRepository(path: string, signal?: AbortSignal | undefined | null): Promise<Repository> |
| 199 | +export declare function cloneRepository(url: string, path: string, options?: RepositoryCloneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository> |
| 200 | +export declare class Repository { |
| 201 | + /** List all remotes for a given repository */ |
| 202 | + remoteNames(): Array<string> |
| 203 | + /** Get remote or throws error is not exists. */ |
| 204 | + getRemote(name: string): RemoteObject |
| 205 | + /** Find remote */ |
| 206 | + findRemote(name: string): RemoteObject | null |
| 207 | + /** Add a remote with the default fetch refspec to the repository’s configuration. */ |
| 208 | + createRemote(name: string, url: string, options?: CreateRemoteOptions | undefined | null): RemoteObject |
| 209 | + /** |
| 210 | + * Download new data and update tips |
| 211 | + * |
| 212 | + * Convenience function to connect to a remote, download the data, disconnect and update the remote-tracking branches. |
| 213 | + */ |
| 214 | + fetchRemote(name: string, refspecs: Array<string>, options?: FetchRemoteOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void> |
| 215 | + /** |
| 216 | + * Perform a push |
| 217 | + * |
| 218 | + * Perform all the steps for a push. If no refspecs are passed then the configured refspecs will be used. |
| 219 | + */ |
| 220 | + pushRemote(name: string, refspecs: Array<string>, options?: PushOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void> |
| 221 | + /** Prune tracking refs that are no longer present on remote */ |
| 222 | + pruneRemote(name: string, options?: PruneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void> |
| 223 | + /** Get the remote’s default branch. */ |
| 224 | + getRemoteDefaultBranch(name: string, signal?: AbortSignal | undefined | null): Promise<string> |
| 225 | + isBare(): boolean |
| 226 | + isShallow(): boolean |
| 227 | + isWorktree(): boolean |
| 228 | + isEmpty(): boolean |
| 229 | + path(): string |
| 230 | + state(): RepositoryState |
| 231 | + workdir(): string | null |
| 232 | +} |
0 commit comments