UNPKG

32.9 kBTypeScriptView Raw
1import * as resp from './response';
2import * as types from './types';
3import { GitError } from './errors';
4
5export interface SimpleGitFactory {
6 (baseDir?: string, options?: Partial<types.SimpleGitOptions>): SimpleGit;
7
8 (baseDir: string): SimpleGit;
9
10 (options: Partial<types.SimpleGitOptions>): SimpleGit;
11}
12
13export type Response<T> = SimpleGit & Promise<T>;
14
15export interface SimpleGitBase {
16 /**
17 * Adds one or more files to source control
18 */
19 add(files: string | string[], callback?: types.SimpleGitTaskCallback<string>): Response<string>;
20
21 /**
22 * Sets the working directory of the subsequent commands.
23 */
24 cwd(
25 directory: { path: string; root?: boolean },
26 callback?: types.SimpleGitTaskCallback<string>
27 ): Response<string>;
28
29 cwd<path extends string>(
30 directory: path,
31 callback?: types.SimpleGitTaskCallback<path>
32 ): Response<path>;
33
34 /**
35 * Compute object ID from a file
36 */
37 hashObject(path: string, callback?: types.SimpleGitTaskCallback): Response<string>;
38
39 hashObject(
40 path: string,
41 write?: boolean,
42 callback?: types.SimpleGitTaskCallback
43 ): Response<string>;
44
45 /**
46 * Initialize a git repo
47 */
48 init(
49 bare: boolean,
50 options?: types.TaskOptions,
51 callback?: types.SimpleGitTaskCallback<resp.InitResult>
52 ): Response<resp.InitResult>;
53
54 init(
55 bare: boolean,
56 callback?: types.SimpleGitTaskCallback<resp.InitResult>
57 ): Response<resp.InitResult>;
58
59 init(
60 options?: types.TaskOptions,
61 callback?: types.SimpleGitTaskCallback<resp.InitResult>
62 ): Response<resp.InitResult>;
63
64 init(callback?: types.SimpleGitTaskCallback<resp.InitResult>): Response<resp.InitResult>;
65
66 /**
67 * Runs a merge, `options` can be either an array of arguments
68 * supported by the [`git merge`](https://git-scm.com/docs/git-merge)
69 * or an options object.
70 *
71 * Conflicts during the merge result in an error response,
72 * the response type whether it was an error or success will be a MergeSummary instance.
73 * When successful, the MergeSummary has all detail from a the PullSummary
74 *
75 * @see https://github.com/steveukx/git-js/blob/master/src/responses/MergeSummary.js
76 * @see https://github.com/steveukx/git-js/blob/master/src/responses/PullSummary.js
77 */
78 merge(
79 options: types.TaskOptions,
80 callback?: types.SimpleGitTaskCallback<resp.MergeResult>
81 ): Response<resp.MergeResult>;
82
83 /**
84 * Merges from one branch to another, equivalent to running `git merge ${remote} ${branch}`, the `options` argument can
85 * either be an array of additional parameters to pass to the command or null / omitted to be ignored.
86 */
87 mergeFromTo<E extends GitError>(
88 remote: string,
89 branch: string,
90 options?: types.TaskOptions,
91 callback?: types.SimpleGitTaskCallback<resp.MergeResult, E>
92 ): Response<resp.MergeResult>;
93
94 mergeFromTo<E extends GitError>(
95 remote: string,
96 branch: string,
97 callback?: types.SimpleGitTaskCallback<resp.MergeResult, E>
98 ): Response<resp.MergeResult>;
99
100 /**
101 * Sets a handler function to be called whenever a new child process is created, the handler function will be called
102 * with the name of the command being run and the stdout & stderr streams used by the ChildProcess.
103 *
104 * @example
105 * require('simple-git')
106 * .outputHandler(function (command, stdout, stderr) {
107 * stdout.pipe(process.stdout);
108 * })
109 * .checkout('https://github.com/user/repo.git');
110 *
111 * @see https://nodejs.org/api/child_process.html#child_process_class_childprocess
112 * @see https://nodejs.org/api/stream.html#stream_class_stream_readable
113 */
114 outputHandler(handler: types.outputHandler | void): this;
115
116 /**
117 * Pushes the current committed changes to a remote, optionally specify the names of the remote and branch to use
118 * when pushing. Supply multiple options as an array of strings in the first argument - see examples below.
119 */
120 push(
121 remote?: string,
122 branch?: string,
123 options?: types.TaskOptions,
124 callback?: types.SimpleGitTaskCallback<resp.PushResult>
125 ): Response<resp.PushResult>;
126
127 push(
128 options?: types.TaskOptions,
129 callback?: types.SimpleGitTaskCallback<resp.PushResult>
130 ): Response<resp.PushResult>;
131
132 push(callback?: types.SimpleGitTaskCallback<resp.PushResult>): Response<resp.PushResult>;
133
134 /**
135 * Stash the local repo
136 */
137 stash(
138 options?: types.TaskOptions,
139 callback?: types.SimpleGitTaskCallback<string>
140 ): Response<string>;
141
142 stash(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
143
144 /**
145 * Show the working tree status.
146 */
147 status(
148 options?: types.TaskOptions,
149 callback?: types.SimpleGitTaskCallback<resp.StatusResult>
150 ): Response<resp.StatusResult>;
151
152 status(callback?: types.SimpleGitTaskCallback<resp.StatusResult>): Response<resp.StatusResult>;
153}
154
155export interface SimpleGit extends SimpleGitBase {
156 /**
157 * Add an annotated tag to the head of the current branch
158 */
159 addAnnotatedTag(
160 tagName: string,
161 tagMessage: string,
162 callback?: types.SimpleGitTaskCallback<{ name: string }>
163 ): Response<{ name: string }>;
164
165 /**
166 * Add config to local git instance for the specified `key` (eg: user.name) and value (eg: 'your name').
167 * Set `append` to true to append to rather than overwrite the key
168 */
169 addConfig(
170 key: string,
171 value: string,
172 append?: boolean,
173 scope?: keyof typeof types.GitConfigScope,
174 callback?: types.SimpleGitTaskCallback<string>
175 ): Response<string>;
176
177 addConfig(
178 key: string,
179 value: string,
180 append?: boolean,
181 callback?: types.SimpleGitTaskCallback<string>
182 ): Response<string>;
183
184 addConfig(
185 key: string,
186 value: string,
187 callback?: types.SimpleGitTaskCallback<string>
188 ): Response<string>;
189
190 /**
191 * Applies a patch to the repo
192 */
193 applyPatch(
194 patches: string | string[],
195 options: types.TaskOptions<types.ApplyOptions>,
196 callback?: types.SimpleGitTaskCallback<string>
197 ): Response<string>;
198
199 applyPatch(
200 patches: string | string[],
201 callback?: types.SimpleGitTaskCallback<string>
202 ): Response<string>;
203
204 /**
205 * Configuration values visible to git in the current working directory
206 */
207 listConfig(
208 scope: keyof typeof types.GitConfigScope,
209 callback?: types.SimpleGitTaskCallback<resp.ConfigListSummary>
210 ): Response<resp.ConfigListSummary>;
211
212 listConfig(
213 callback?: types.SimpleGitTaskCallback<resp.ConfigListSummary>
214 ): Response<resp.ConfigListSummary>;
215
216 /**
217 * Adds a remote to the list of remotes.
218 *
219 * - `remoteName` Name of the repository - eg "upstream"
220 * - `remoteRepo` Fully qualified SSH or HTTP(S) path to the remote repo
221 * - `options` Optional additional settings permitted by the `git remote add` command, merged into the command prior to the repo name and remote url
222 */
223 addRemote(
224 remoteName: string,
225 remoteRepo: string,
226 options?: types.TaskOptions,
227 callback?: types.SimpleGitTaskCallback<string>
228 ): Response<string>;
229
230 addRemote(
231 remoteName: string,
232 remoteRepo: string,
233 callback?: types.SimpleGitTaskCallback<string>
234 ): Response<string>;
235
236 /**
237 * Add a lightweight tag to the head of the current branch
238 */
239 addTag(
240 name: string,
241 callback?: types.SimpleGitTaskCallback<{ name: string }>
242 ): Response<{ name: string }>;
243
244 /**
245 * Equivalent to `catFile` but will return the native `Buffer` of content from the git command's stdout.
246 */
247 binaryCatFile(options: string[], callback?: types.SimpleGitTaskCallback<any>): Response<any>;
248
249 /**
250 * List all branches
251 */
252 branch(
253 options?: types.TaskOptions,
254 callback?: types.SimpleGitTaskCallback<resp.BranchSummary>
255 ): Response<resp.BranchSummary>;
256
257 /**
258 * List of local branches
259 */
260 branchLocal(
261 callback?: types.SimpleGitTaskCallback<resp.BranchSummary>
262 ): Response<resp.BranchSummary>;
263
264 /**
265 * Returns a list of objects in a tree based on commit hash.
266 * Passing in an object hash returns the object's content, size, and type.
267 *
268 * Passing "-p" will instruct cat-file to determine the object type, and display its formatted contents.
269 *
270 * @see https://git-scm.com/docs/git-cat-file
271 */
272 catFile(options: string[], callback?: types.SimpleGitTaskCallback<string>): Response<string>;
273
274 catFile(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
275
276 /**
277 * Check if a pathname or pathnames are excluded by .gitignore
278 *
279 */
280 checkIgnore(
281 pathNames: string[],
282 callback?: types.SimpleGitTaskCallback<string[]>
283 ): Response<string[]>;
284
285 checkIgnore(path: string, callback?: types.SimpleGitTaskCallback<string[]>): Response<string[]>;
286
287 /**
288 * Validates that the current working directory is a valid git repo file path.
289 *
290 * To make a more specific assertion of the repo, add the `action` argument:
291 *
292 * - `bare` to validate that the working directory is inside a bare repo.
293 * - `root` to validate that the working directory is the root of a repo.
294 * - `tree` (default value when omitted) to simply validate that the working
295 * directory is the descendent of a repo
296 */
297 checkIsRepo(
298 action?: types.CheckRepoActions,
299 callback?: types.SimpleGitTaskCallback<boolean>
300 ): Response<boolean>;
301
302 checkIsRepo(callback?: types.SimpleGitTaskCallback<boolean>): Response<boolean>;
303
304 /**
305 * Checkout a tag or revision, any number of additional arguments can be passed to the `git checkout` command
306 * by supplying either a string or array of strings as the `what` parameter.
307 */
308 checkout(
309 what: string,
310 options?: types.TaskOptions,
311 callback?: types.SimpleGitTaskCallback<string>
312 ): Response<string>;
313
314 checkout(what: string, callback?: types.SimpleGitTaskCallback<string>): Response<string>;
315
316 checkout(
317 options?: types.TaskOptions,
318 callback?: types.SimpleGitTaskCallback<string>
319 ): Response<string>;
320
321 /**
322 * Checkout a remote branch - equivalent to `git checkout -b ${branchName} ${startPoint}`
323 *
324 * - branchName name of branch.
325 * - startPoint (e.g origin/development).
326 */
327 checkoutBranch(
328 branchName: string,
329 startPoint: string,
330 callback?: types.SimpleGitTaskCallback<void>
331 ): Response<void>;
332
333 checkoutBranch(
334 branchName: string,
335 startPoint: string,
336 options?: types.TaskOptions,
337 callback?: types.SimpleGitTaskCallback<void>
338 ): Response<void>;
339
340 /**
341 * Internally uses pull and tags to get the list of tags then checks out the latest tag.
342 */
343 checkoutLatestTag(
344 branchName: string,
345 startPoint: string,
346 callback?: types.SimpleGitTaskCallback<void>
347 ): Response<void>;
348
349 /**
350 * Checkout a local branch - equivalent to `git checkout -b ${branchName}`
351 */
352 checkoutLocalBranch(
353 branchName: string,
354 callback?: types.SimpleGitTaskCallback<void>
355 ): Response<void>;
356
357 checkoutLocalBranch(
358 branchName: string,
359 options?: types.TaskOptions,
360 callback?: types.SimpleGitTaskCallback<void>
361 ): Response<void>;
362
363 /**
364 * Deletes unwanted content from the local repo - when supplying the first argument as
365 * an array of `CleanOptions`, the array must include one of `CleanOptions.FORCE` or
366 * `CleanOptions.DRY_RUN`.
367 *
368 * eg:
369 *
370 * ```typescript
371 await git.clean(CleanOptions.FORCE);
372 await git.clean(CleanOptions.DRY_RUN + CleanOptions.RECURSIVE);
373 await git.clean(CleanOptions.FORCE, ['./path']);
374 await git.clean(CleanOptions.IGNORED + CleanOptions.FORCE, {'./path': null});
375 * ```
376 */
377 clean(
378 args: types.CleanOptions[],
379 options?: types.TaskOptions,
380 callback?: types.SimpleGitTaskCallback<resp.CleanSummary>
381 ): Response<resp.CleanSummary>;
382
383 clean(
384 mode: types.CleanMode | string,
385 options?: types.TaskOptions,
386 callback?: types.SimpleGitTaskCallback<resp.CleanSummary>
387 ): Response<resp.CleanSummary>;
388
389 clean(
390 mode: types.CleanMode | string,
391 callback?: types.SimpleGitTaskCallback<resp.CleanSummary>
392 ): Response<resp.CleanSummary>;
393
394 clean(options?: types.TaskOptions): Response<resp.CleanSummary>;
395
396 clean(callback?: types.SimpleGitTaskCallback<resp.CleanSummary>): Response<resp.CleanSummary>;
397
398 /**
399 * Clears the queue of pending commands and returns the wrapper instance for chaining.
400 */
401 clearQueue(): this;
402
403 /**
404 * Clone a repository into a new directory.
405 *
406 * - repoPath repository url to clone e.g. https://github.com/steveukx/git-js.git
407 * - localPath local folder path to clone to.
408 * - options supported by [git](https://git-scm.com/docs/git-clone).
409 */
410 clone(
411 repoPath: string,
412 localPath: string,
413 options?: types.TaskOptions,
414 callback?: types.SimpleGitTaskCallback<string>
415 ): Response<string>;
416
417 clone(
418 repoPath: string,
419 options?: types.TaskOptions,
420 callback?: types.SimpleGitTaskCallback<string>
421 ): Response<string>;
422
423 /**
424 * Commits changes in the current working directory - when specific file paths are supplied, only changes on those
425 * files will be committed.
426 */
427 commit(
428 message: string | string[],
429 files?: string | string[],
430 options?: types.Options,
431 callback?: types.SimpleGitTaskCallback<resp.CommitResult>
432 ): Response<resp.CommitResult>;
433
434 commit(
435 message: string | string[],
436 options?: types.TaskOptions,
437 callback?: types.SimpleGitTaskCallback<resp.CommitResult>
438 ): Response<resp.CommitResult>;
439
440 commit(
441 message: string | string[],
442 files?: string | string[],
443 callback?: types.SimpleGitTaskCallback<resp.CommitResult>
444 ): Response<resp.CommitResult>;
445
446 commit(
447 message: string | string[],
448 callback?: types.SimpleGitTaskCallback<resp.CommitResult>
449 ): Response<resp.CommitResult>;
450
451 /**
452 * Retrieves `git` disk usage information, see https://git-scm.com/docs/git-count-objects
453 */
454 countObjects(
455 callback?: types.SimpleGitTaskCallback<types.VersionResult>
456 ): Response<types.CountObjectsResult>;
457
458 /**
459 * Sets the path to a custom git binary, should either be `git` when there is an installation of git available on
460 * the system path, or a fully qualified path to the executable.
461 */
462 customBinary(command: Exclude<types.SimpleGitOptions['binary'], undefined>): this;
463
464 /**
465 * Delete one local branch. Supply the branchName as a string to return a
466 * single `BranchDeletionSummary` instances.
467 *
468 * - branchName name of branch
469 * - forceDelete (optional, defaults to false) set to true to forcibly delete unmerged branches
470 */
471 deleteLocalBranch(
472 branchName: string,
473 forceDelete?: boolean,
474 callback?: types.SimpleGitTaskCallback<resp.BranchSingleDeleteResult>
475 ): Response<resp.BranchSingleDeleteResult>;
476
477 deleteLocalBranch(
478 branchName: string,
479 callback?: types.SimpleGitTaskCallback<resp.BranchSingleDeleteResult>
480 ): Response<resp.BranchSingleDeleteResult>;
481
482 /**
483 * Delete one or more local branches. Supply the branchName as a string to return a
484 * single `BranchDeletionSummary` or as an array of branch names to return an array of
485 * `BranchDeletionSummary` instances.
486 *
487 * - branchNames name of branch or array of branch names
488 * - forceDelete (optional, defaults to false) set to true to forcibly delete unmerged branches
489 */
490 deleteLocalBranches(
491 branchNames: string[],
492 forceDelete?: boolean,
493 callback?: types.SimpleGitTaskCallback<resp.BranchMultiDeleteResult>
494 ): Response<resp.BranchMultiDeleteResult>;
495
496 /**
497 * Get the diff of the current repo compared to the last commit with a set of options supplied as a string.
498 */
499 diff(
500 options?: types.TaskOptions,
501 callback?: types.SimpleGitTaskCallback<string>
502 ): Response<string>;
503
504 /**
505 * Gets a summary of the diff for files in the repo, uses the `git diff --stat` format to calculate changes.
506 *
507 * in order to get staged (only): `--cached` or `--staged`.
508 */
509 diffSummary(
510 command: string | number,
511 options: types.TaskOptions,
512 callback?: types.SimpleGitTaskCallback<resp.DiffResult>
513 ): Response<resp.DiffResult>;
514
515 diffSummary(
516 command: string | number,
517 callback?: types.SimpleGitTaskCallback<resp.DiffResult>
518 ): Response<resp.DiffResult>;
519
520 diffSummary(
521 options: types.TaskOptions,
522 callback?: types.SimpleGitTaskCallback<resp.DiffResult>
523 ): Response<resp.DiffResult>;
524
525 diffSummary(callback?: types.SimpleGitTaskCallback<resp.DiffResult>): Response<resp.DiffResult>;
526
527 /**
528 * Sets an environment variable for the spawned child process, either supply both a name and value as strings or
529 * a single object to entirely replace the current environment variables.
530 *
531 * @param {string|Object} name
532 * @param {string} [value]
533 */
534 env(name: string, value: string): this;
535
536 env(env: object): this;
537
538 /**
539 * Calls the supplied `handle` function at the next step in the chain, used to run arbitrary functions synchronously
540 * before the next task in the git API.
541 */
542 exec(handle: () => void): Response<void>;
543
544 /**
545 * Updates the local working copy database with changes from the default remote repo and branch.
546 */
547 fetch(
548 remote: string,
549 branch: string,
550 options?: types.TaskOptions,
551 callback?: types.SimpleGitTaskCallback<resp.FetchResult>
552 ): Response<resp.FetchResult>;
553
554 fetch(
555 remote: string,
556 branch: string,
557 callback?: types.SimpleGitTaskCallback<resp.FetchResult>
558 ): Response<resp.FetchResult>;
559
560 fetch(
561 remote: string,
562 options?: types.TaskOptions,
563 callback?: types.SimpleGitTaskCallback<resp.FetchResult>
564 ): Response<resp.FetchResult>;
565
566 fetch(
567 options?: types.TaskOptions,
568 callback?: types.SimpleGitTaskCallback<resp.FetchResult>
569 ): Response<resp.FetchResult>;
570
571 fetch(callback?: types.SimpleGitTaskCallback<resp.FetchResult>): Response<resp.FetchResult>;
572
573 /**
574 * Gets the commit hash of the first commit in the repo
575 */
576 firstCommit(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
577
578 /**
579 * Gets the current value of a configuration property by it key, optionally specify the scope in which
580 * to run the command (omit / set to `undefined` to check in the complete overlaid configuration visible
581 * to the `git` process).
582 */
583 getConfig(
584 key: string,
585 scope?: keyof typeof types.GitConfigScope,
586 callback?: types.SimpleGitTaskCallback<string>
587 ): Response<resp.ConfigGetResult>;
588
589 /**
590 * Gets the currently available remotes, setting the optional verbose argument to true includes additional
591 * detail on the remotes themselves.
592 */
593 getRemotes(
594 callback?: types.SimpleGitTaskCallback<types.RemoteWithoutRefs[]>
595 ): Response<types.RemoteWithoutRefs[]>;
596
597 getRemotes(
598 verbose?: false,
599 callback?: types.SimpleGitTaskCallback<types.RemoteWithoutRefs[]>
600 ): Response<types.RemoteWithoutRefs[]>;
601
602 getRemotes(
603 verbose: true,
604 callback?: types.SimpleGitTaskCallback<types.RemoteWithRefs[]>
605 ): Response<types.RemoteWithRefs[]>;
606
607 /**
608 * Search for files matching the supplied search terms
609 */
610 grep(
611 searchTerm: string | types.GitGrepQuery,
612 callback?: types.SimpleGitTaskCallback<resp.GrepResult>
613 ): Response<resp.GrepResult>;
614
615 grep(
616 searchTerm: string | types.GitGrepQuery,
617 options?: types.TaskOptions,
618 callback?: types.SimpleGitTaskCallback<resp.GrepResult>
619 ): Response<resp.GrepResult>;
620
621 /**
622 * List remotes by running the `ls-remote` command with any number of arbitrary options
623 * in either array of object form.
624 */
625 listRemote(
626 args?: types.TaskOptions,
627 callback?: types.SimpleGitTaskCallback<string>
628 ): Response<string>;
629
630 /**
631 * Show commit logs from `HEAD` to the first commit.
632 * If provided between `options.from` and `options.to` tags or branch.
633 *
634 * You can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered.
635 *
636 * To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on.
637 *
638 * By default the following fields will be part of the result:
639 * `hash`: full commit hash
640 * `date`: author date, ISO 8601-like format
641 * `message`: subject + ref names, like the --decorate option of git-log
642 * `author_name`: author name
643 * `author_email`: author mail
644 * You can specify `options.format` to be an mapping from key to a format option like `%H` (for commit hash).
645 * The fields specified in `options.format` will be the fields in the result.
646 *
647 * Options can also be supplied as a standard options object for adding custom properties supported by the git log command.
648 * For any other set of options, supply options as an array of strings to be appended to the git log command.
649 *
650 * @returns Response<ListLogSummary>
651 *
652 * @see https://git-scm.com/docs/git-log
653 */
654 log<T = types.DefaultLogFields>(
655 options?: types.TaskOptions | types.LogOptions<T>,
656 callback?: types.SimpleGitTaskCallback<resp.LogResult<T>>
657 ): Response<resp.LogResult<T>>;
658
659 /**
660 * Mirror a git repo
661 *
662 * Equivalent to `git.clone(repoPath, localPath, ['--mirror'])`, `clone` allows
663 * for additional task options.
664 */
665 mirror(
666 repoPath: string,
667 localPath: string,
668 callback?: types.SimpleGitTaskCallback<string>
669 ): Response<string>;
670
671 /**
672 * Moves one or more files to a new destination.
673 *
674 * @see https://git-scm.com/docs/git-mv
675 */
676 mv(
677 from: string | string[],
678 to: string,
679 callback?: types.SimpleGitTaskCallback<resp.MoveSummary>
680 ): Response<resp.MoveSummary>;
681
682 /**
683 * Fetch from and integrate with another repository or a local branch. In the case that the `git pull` fails with a
684 * recognised fatal error, the exception thrown by this function will be a `GitResponseError<PullFailedResult>`.
685 */
686 pull(
687 remote?: string,
688 branch?: string,
689 options?: types.TaskOptions,
690 callback?: types.SimpleGitTaskCallback<resp.PullResult>
691 ): Response<resp.PullResult>;
692
693 pull(
694 options?: types.TaskOptions,
695 callback?: types.SimpleGitTaskCallback<resp.PullResult>
696 ): Response<resp.PullResult>;
697
698 pull(callback?: types.SimpleGitTaskCallback<resp.PullResult>): Response<resp.PullResult>;
699
700 /**
701 * Pushes the current tag changes to a remote which can be either a URL or named remote. When not specified uses the
702 * default configured remote spec.
703 */
704 pushTags(
705 remote: string,
706 options?: types.TaskOptions,
707 callback?: types.SimpleGitTaskCallback<resp.PushResult>
708 ): Response<resp.PushResult>;
709
710 pushTags(
711 options?: types.TaskOptions,
712 callback?: types.SimpleGitTaskCallback<resp.PushResult>
713 ): Response<resp.PushResult>;
714
715 pushTags(callback?: types.SimpleGitTaskCallback<resp.PushResult>): Response<resp.PushResult>;
716
717 /**
718 * Executes any command against the git binary.
719 */
720 raw(
721 commands: string | string[] | types.TaskOptions,
722 callback?: types.SimpleGitTaskCallback<string>
723 ): Response<string>;
724
725 raw(
726 options: types.TaskOptions,
727 callback?: types.SimpleGitTaskCallback<string>
728 ): Response<string>;
729
730 raw(...commands: string[]): Response<string>;
731
732 // leading varargs with trailing options/callback
733 raw(
734 a: string,
735 options: types.TaskOptions,
736 callback?: types.SimpleGitTaskCallback<string>
737 ): Response<string>;
738
739 raw(
740 a: string,
741 b: string,
742 options: types.TaskOptions,
743 callback?: types.SimpleGitTaskCallback<string>
744 ): Response<string>;
745
746 raw(
747 a: string,
748 b: string,
749 c: string,
750 options: types.TaskOptions,
751 callback?: types.SimpleGitTaskCallback<string>
752 ): Response<string>;
753
754 raw(
755 a: string,
756 b: string,
757 c: string,
758 d: string,
759 options: types.TaskOptions,
760 callback?: types.SimpleGitTaskCallback<string>
761 ): Response<string>;
762
763 raw(
764 a: string,
765 b: string,
766 c: string,
767 d: string,
768 e: string,
769 options: types.TaskOptions,
770 callback?: types.SimpleGitTaskCallback<string>
771 ): Response<string>;
772
773 // leading varargs with trailing callback
774 raw(a: string, callback?: types.SimpleGitTaskCallback<string>): Response<string>;
775
776 raw(a: string, b: string, callback?: types.SimpleGitTaskCallback<string>): Response<string>;
777
778 raw(
779 a: string,
780 b: string,
781 c: string,
782 callback?: types.SimpleGitTaskCallback<string>
783 ): Response<string>;
784
785 raw(
786 a: string,
787 b: string,
788 c: string,
789 d: string,
790 callback?: types.SimpleGitTaskCallback<string>
791 ): Response<string>;
792
793 raw(
794 a: string,
795 b: string,
796 c: string,
797 d: string,
798 e: string,
799 callback?: types.SimpleGitTaskCallback<string>
800 ): Response<string>;
801
802 /**
803 * Rebases the current working copy. Options can be supplied either as an array of string parameters
804 * to be sent to the `git rebase` command, or a standard options object.
805 */
806 rebase(
807 options?: types.TaskOptions,
808 callback?: types.SimpleGitTaskCallback<string>
809 ): Response<string>;
810
811 rebase(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
812
813 /**
814 * Call any `git remote` function with arguments passed as an array of strings.
815 */
816 remote(
817 options: string[],
818 callback?: types.SimpleGitTaskCallback<void | string>
819 ): Response<void | string>;
820
821 /**
822 * Removes an entry from the list of remotes.
823 *
824 * - remoteName Name of the repository - eg "upstream"
825 */
826 removeRemote(remoteName: string, callback?: types.SimpleGitTaskCallback<void>): Response<void>;
827
828 /**
829 * Reset a repo. Called without arguments this is a soft reset for the whole repo,
830 * for explicitly setting the reset mode, supply the first argument as one of the
831 * supported reset modes.
832 *
833 * Trailing options argument can be either a string array, or an extension of the
834 * ResetOptions, use this argument for supplying arbitrary additional arguments,
835 * such as restricting the pathspec.
836 *
837 * ```typescript
838 // equivalent to each other
839 simpleGit().reset(ResetMode.HARD, ['--', 'my-file.txt']);
840 simpleGit().reset(['--hard', '--', 'my-file.txt']);
841 simpleGit().reset(ResetMode.HARD, {'--': null, 'my-file.txt': null});
842 simpleGit().reset({'--hard': null, '--': null, 'my-file.txt': null});
843 ```
844 */
845 reset(
846 mode: types.ResetMode,
847 options?: types.TaskOptions<types.ResetOptions>,
848 callback?: types.SimpleGitTaskCallback<string>
849 ): Response<string>;
850
851 reset(mode: types.ResetMode, callback?: types.SimpleGitTaskCallback<string>): Response<string>;
852
853 reset(
854 options?: types.TaskOptions<types.ResetOptions>,
855 callback?: types.SimpleGitTaskCallback<string>
856 ): Response<string>;
857
858 /**
859 * Revert one or more commits in the local working copy
860 *
861 * - commit The commit to revert. Can be any hash, offset (eg: `HEAD~2`) or range (eg: `master~5..master~2`)
862 */
863 revert(
864 commit: String,
865 options?: types.TaskOptions,
866 callback?: types.SimpleGitTaskCallback<void>
867 ): Response<void>;
868
869 revert(commit: String, callback?: types.SimpleGitTaskCallback<void>): Response<void>;
870
871 /**
872 * Passes the supplied options to `git rev-parse` and returns the string response. Options can be either a
873 * string array or `Options` object of options compatible with the [rev-parse](https://git-scm.com/docs/git-rev-parse)
874 *
875 * Example uses of `rev-parse` include converting friendly commit references (ie: branch names) to SHA1 hashes
876 * and retrieving meta details about the current repo (eg: the root directory, and whether it was created as
877 * a bare repo).
878 */
879 revparse(
880 option: string,
881 options?: types.TaskOptions,
882 callback?: types.SimpleGitTaskCallback<string>
883 ): Response<string>;
884
885 revparse(
886 options?: types.TaskOptions,
887 callback?: types.SimpleGitTaskCallback<string>
888 ): Response<string>;
889
890 /**
891 * Removes the named files from source control.
892 */
893 rm(paths: string | string[], callback?: types.SimpleGitTaskCallback<void>): Response<void>;
894
895 /**
896 * Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
897 * completely remove the files, use `rm`.
898 */
899 rmKeepLocal(
900 paths: string | string[],
901 callback?: types.SimpleGitTaskCallback<void>
902 ): Response<void>;
903
904 /**
905 * Show various types of objects, for example the file at a certain commit
906 */
907 show(
908 option: string | types.TaskOptions,
909 callback?: types.SimpleGitTaskCallback<string>
910 ): Response<string>;
911
912 show(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
913
914 showBuffer(option: string | types.TaskOptions): Response<Buffer>;
915
916 /**
917 * @deprecated
918 *
919 * From version 2.7.0, use of `silent` is deprecated in favour of using the `debug` library, this method will
920 * be removed in version 3.x.
921 *
922 * Please see the [readme](https://github.com/steveukx/git-js/blob/master/readme.md#enable-logging) for more details.
923 *
924 * Disables/enables the use of the console for printing warnings and errors, by default messages are not shown in
925 * a production environment.
926 *
927 * @param {boolean} silence
928 */
929 silent(silence?: boolean): this;
930
931 /**
932 * List the stash(s) of the local repo
933 */
934 stashList(
935 options?: types.TaskOptions,
936 callback?: types.SimpleGitTaskCallback<resp.LogResult>
937 ): Response<resp.LogResult>;
938
939 stashList(callback?: types.SimpleGitTaskCallback<resp.LogResult>): Response<resp.LogResult>;
940
941 /**
942 * Call any `git submodule` function with arguments passed as an array of strings.
943 */
944 subModule(
945 options?: types.TaskOptions,
946 callback?: types.SimpleGitTaskCallback<string>
947 ): Response<string>;
948
949 /**
950 * Add a submodule
951 */
952 submoduleAdd(
953 repo: string,
954 path: string,
955 callback?: types.SimpleGitTaskCallback<string>
956 ): Response<string>;
957
958 /**
959 * Initialise submodules
960 */
961 submoduleInit(
962 moduleName: string,
963 options?: types.TaskOptions,
964 callback?: types.SimpleGitTaskCallback<string>
965 ): Response<string>;
966
967 submoduleInit(
968 moduleName: string,
969 callback?: types.SimpleGitTaskCallback<string>
970 ): Response<string>;
971
972 submoduleInit(
973 options?: types.TaskOptions,
974 callback?: types.SimpleGitTaskCallback<string>
975 ): Response<string>;
976
977 submoduleInit(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
978
979 /**
980 * Update submodules
981 */
982 submoduleUpdate(
983 moduleName: string,
984 options?: types.TaskOptions,
985 callback?: types.SimpleGitTaskCallback<string>
986 ): Response<string>;
987
988 submoduleUpdate(
989 moduleName: string,
990 callback?: types.SimpleGitTaskCallback<string>
991 ): Response<string>;
992
993 submoduleUpdate(
994 options?: types.TaskOptions,
995 callback?: types.SimpleGitTaskCallback<string>
996 ): Response<string>;
997
998 submoduleUpdate(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
999
1000 /**
1001 * List all tags. When using git 2.7.0 or above, include an options object with `"--sort": "property-name"` to
1002 * sort the tags by that property instead of using the default semantic versioning sort.
1003 *
1004 * Note, supplying this option when it is not supported by your Git version will cause the operation to fail.
1005 */
1006 tag(
1007 options?: types.TaskOptions,
1008 callback?: types.SimpleGitTaskCallback<string>
1009 ): Response<string>;
1010
1011 /**
1012 * Gets a list of tagged versions.
1013 */
1014 tags(
1015 options?: types.TaskOptions,
1016 callback?: types.SimpleGitTaskCallback<resp.TagResult>
1017 ): Response<resp.TagResult>;
1018
1019 tags(callback?: types.SimpleGitTaskCallback<resp.TagResult>): Response<resp.TagResult>;
1020
1021 /**
1022 * Updates repository server info
1023 */
1024 updateServerInfo(callback?: types.SimpleGitTaskCallback<string>): Response<string>;
1025
1026 /**
1027 * Retrieves `git` version information, including whether `git` is installed on the `PATH`
1028 */
1029 version(
1030 callback?: types.SimpleGitTaskCallback<types.VersionResult>
1031 ): Response<types.VersionResult>;
1032}