Update Git documentation (2.30.0)

pull/1456/head
Simon Legner 4 years ago
parent 8f17cfa136
commit 3600a9ff3b

@ -1,7 +1,7 @@
module Docs
class Git < UrlScraper
self.type = 'git'
self.release = '2.29.2'
self.release = '2.30.0'
self.base_url = 'https://git-scm.com/docs'
self.initial_paths = %w(/git.html)
self.links = {

@ -0,0 +1 @@
tidelift: "npm/fast-json-stable-stringify"

@ -0,0 +1,8 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # not working due missing www.
open_collective: #
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: https://www.patreon.com/webreflection

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/is-core-module
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

@ -0,0 +1,54 @@
name: 'Tests: node.js'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '>=4'
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
minors:
needs: [matrix, latest]
name: 'non-latest minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
node:
name: 'node 4+'
needs: [latest, minors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

@ -0,0 +1,58 @@
name: 'Tests: node.js (io.js)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: 'iojs'
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
skip-ls-check: true
minors:
needs: [matrix, latest]
name: 'non-latest minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
skip-ls-check: true
node:
name: 'io.js'
needs: [latest, minors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

@ -0,0 +1,26 @@
name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
pretest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run pretest'
with:
node-version: 'lts/*'
command: 'pretest'
posttest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run posttest'
with:
node-version: 'lts/*'
command: 'posttest'

@ -0,0 +1,58 @@
name: 'Tests: node.js (0.x)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
stable: ${{ steps.set-matrix.outputs.requireds }}
unstable: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '0.x'
stable:
needs: [matrix]
name: 'stable minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.stable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
unstable:
needs: [matrix, stable]
name: 'unstable minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.unstable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
node:
name: 'node 0.x'
needs: [stable, unstable]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

@ -0,0 +1,15 @@
name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@ -0,0 +1,14 @@
name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@ -0,0 +1,54 @@
name: 'Tests: node.js'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '>=4'
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
minors:
needs: [matrix, latest]
name: 'non-latest minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
node:
name: 'node 4+'
needs: [latest, minors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

@ -0,0 +1,55 @@
name: 'Tests: node.js (io.js)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: 'iojs'
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
minors:
needs: [matrix, latest]
name: 'non-latest minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
node:
name: 'io.js'
needs: [latest, minors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

@ -0,0 +1,27 @@
name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
pretest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run pretest'
with:
node-version: 'lts/*'
command: 'pretest'
posttest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run posttest'
with:
node-version: 'lts/*'
command: 'posttest'

@ -0,0 +1,55 @@
name: 'Tests: node.js (0.x)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
stable: ${{ steps.set-matrix.outputs.requireds }}
unstable: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '0.x'
stable:
needs: [matrix]
name: 'stable minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.stable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
unstable:
needs: [matrix, stable]
name: 'unstable minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.unstable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
node:
name: 'node 0.x'
needs: [stable, unstable]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

@ -0,0 +1,15 @@
name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@ -0,0 +1,14 @@
name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

20
node_modules/simple-git/LICENSE generated vendored

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2015 Steve King
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,74 @@
{
"_from": "simple-git@^1.70.0",
"_id": "simple-git@1.132.0",
"_inBundle": false,
"_integrity": "sha512-xauHm1YqCTom1sC9eOjfq3/9RKiUA9iPnxBbrY2DdL8l4ADMu0jjM5l5lphQP5YWNqAL2aXC/OeuQ76vHtW5fg==",
"_location": "/simple-git",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "simple-git@^1.70.0",
"name": "simple-git",
"escapedName": "simple-git",
"rawSpec": "^1.70.0",
"saveSpec": null,
"fetchSpec": "^1.70.0"
},
"_requiredBy": [
"/bulk-decaffeinate"
],
"_resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.132.0.tgz",
"_shasum": "53ac4c5ec9e74e37c2fd461e23309f22fcdf09b1",
"_spec": "simple-git@^1.70.0",
"_where": "/home/simon/src/devdocs/node_modules/bulk-decaffeinate",
"author": {
"name": "Steve King",
"email": "steve@mydev.co"
},
"bugs": {
"url": "https://github.com/steveukx/git-js/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Steve King",
"email": "steve@mydev.co"
}
],
"dependencies": {
"debug": "^4.0.1"
},
"deprecated": false,
"description": "Simple GIT interface for node.js",
"devDependencies": {
"@kwsites/test-runner": "^0.1.1",
"sinon": "^7.3.2"
},
"files": [
"promise.*",
"src/",
"typings/"
],
"homepage": "https://github.com/steveukx/git-js#readme",
"keywords": [
"git",
"source control",
"vcs"
],
"license": "MIT",
"main": "./src/index.js",
"name": "simple-git",
"repository": {
"type": "git",
"url": "git://github.com/steveukx/git-js.git"
},
"scripts": {
"postversion": "npm publish && git push && git push --tags",
"preversion": "yarn test",
"test": "runner test/**/test*.js ",
"test:integration": "runner test/integration/test*.js",
"test:unit": "runner test/unit/test*.js"
},
"version": "1.132.0"
}

@ -0,0 +1,576 @@
import * as resp from "./typings/response";
declare function simplegit(basePath?: string): simplegit.SimpleGit;
declare namespace simplegit {
interface SimpleGit {
/**
* Adds one or more files to source control
*
* @param {string|string[]} files
* @returns {Promise<void>}
*/
add(files: string | string[]): Promise<void>;
/**
* Add an annotated tag to the head of the current branch
*
* @param {string} tagName
* @param {string} tagMessage
* @returns {Promise<void>}
*/
addAnnotatedTag(tagName: string, tagMessage: string): Promise<void>;
/**
* Add config to local git instance
*
* @param {string} key configuration key (e.g user.name)
* @param {string} value for the given key (e.g your name)
* @returns {Promise<string>}
*/
addConfig(key: string, value: string): Promise<string>;
/**
* Adds a remote to the list of remotes.
*
* @param {string} remoteName Name of the repository - eg "upstream"
* @param {string} remoteRepo Fully qualified SSH or HTTP(S) path to the remote repo
* @returns {Promise<void>}
*/
addRemote(remoteName: string, remoteRepo: string): Promise<void>;
/**
* Add a lightweight tag to the head of the current branch
*
* @param {string} name
* @returns {Promise<string>}
*/
addTag(name: string): Promise<string>;
/**
* Equivalent to `catFile` but will return the native `Buffer` of content from the git command's stdout.
*
* @param {string[]} options
*/
binaryCatFile(options: string[]): Promise<any>;
/**
* List all branches
*/
branch(): Promise<BranchSummary>;
branch(options: Options | string[]): Promise<BranchSummary>;
/**
* List of local branches
*
* @returns {Promise<BranchSummary>}
*/
branchLocal(): Promise<BranchSummary>;
/**
* Returns a list of objects in a tree based on commit hash.
* Passing in an object hash returns the object's content, size, and type.
*
* Passing "-p" will instruct cat-file to determine the object type, and display its formatted contents.
*
* @param {string[]} [options]
* @returns {Promise<string>}
*
* @see https://git-scm.com/docs/git-cat-file
*/
catFile(options: string[]): Promise<string>;
/**
* Check if a pathname or pathnames are excluded by .gitignore
*
* @param {string|string[]} pathnames
*/
checkIgnore(pathnames: string[]): Promise<string[]>;
checkIgnore(path: string): Promise<string[]>;
/**
* Validates that the current repo is a Git repo.
*
* @returns {Promise<boolean>}
*/
checkIsRepo(): Promise<boolean>;
/**
* Checkout a tag or revision, any number of additional arguments can be passed to the `git* checkout` command
by supplying either a string or array of strings as the `what` parameter.
*
* @param {(string | string[])} what one or more commands to pass to `git checkout`.
* @returns {Promise<void>}
*/
checkout(what: string | string[]): Promise<void>;
/**
* Checkout a remote branch.
*
* @param {string} branchName name of branch.
* @param {string} startPoint (e.g origin/development).
* @returns {Promise<void>}
*/
checkoutBranch(branchName: string, startPoint: string): Promise<void>;
/**
* Internally uses pull and tags to get the list of tags then checks out the latest tag.
*/
checkoutLatestTag(branchName: string, startPoint: string): Promise<void>;
/**
* Checkout a local branch
*
* @param {string} branchName name of branch.
* @returns {Promise<void>}
*/
checkoutLocalBranch(branchName: string): Promise<void>;
/**
* @param {string} mode Required parameter "n" or "f"
* @param {string[]} options
*/
clean(
mode: 'd' | 'f' | 'i' | 'n' | 'q' | 'x' | 'X',
options?: string[]
): Promise<string>;
/**
* Clears the queue of pending commands and returns the wrapper instance for chaining.
*/
clearQueue(): this;
/**
* Clone a repository into a new directory.
*
* @param {string} repoPath repository url to clone e.g. https://github.com/steveukx/git-js.git
* @param {string} localPath local folder path to clone to.
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-clone).
* @returns {Promise<void>}
*/
clone(repoPath: string, localPath: string, options?: Options | string[]): Promise<string>;
clone(repoPath: string, options?: Options | string[]): Promise<string>;
/**
* Commits changes in the current working directory - when specific file paths are supplied, only changes on those
* files will be committed.
*
* @param {string|string[]} message
* @param {string|string[]} [files]
* @param {Object} [options]
*/
commit(
message: string | string[],
files?: string | string[],
options?: Options
): Promise<resp.CommitSummary>;
/**
* Sets the path to a custom git binary, should either be `git` when there is an installation of git available on
* the system path, or a fully qualified path to the executable.
*
* @param {string} command
*/
customBinary(command: string): this;
/**
* Sets the working directory of the subsequent commands.
*
* @param {string} workingDirectory
*/
cwd<path extends string>(workingDirectory: path): Promise<path>;
/**
* Delete a local branch
*
* @param {string} branchName name of branch
*/
deleteLocalBranch(branchName: string):
Promise<resp.BranchDeletionSummary>;
/**
* Get the diff of the current repo compared to the last commit with a set of options supplied as a string.
*
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-diff).
* @returns {Promise<string>} raw string result.
*/
diff(options?: string[]): Promise<string>;
/**
* Gets a summary of the diff for files in the repo, uses the `git diff --stat` format to calculate changes.
*
* in order to get staged (only): `--cached` or `--staged`.
*
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-diff).
* @returns {Promise<DiffResult>} Parsed diff summary result.
*/
diffSummary(options?: string[]): Promise<DiffResult>;
/**
* Sets an environment variable for the spawned child process, either supply both a name and value as strings or
* a single object to entirely replace the current environment variables.
*
* @param {string|Object} name
* @param {string} [value]
*/
env(name: string, value: string): this;
env(env: object): this;
/**
* Updates the local working copy database with changes from the default remote repo and branch.
*
* @param {string | string[]} [remote] remote to fetch from.
* @param {string} [branch] branch to fetch from.
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-fetch).
* @returns {Promise<FetchResult>} Parsed fetch result.
*/
fetch(remote?: string | string[], branch?: string, options?: Options): Promise<FetchResult>;
/**
* Gets the currently available remotes, setting the optional verbose argument to true includes additional
* detail on the remotes themselves.
*
* @param {boolean} [verbose=false]
*/
getRemotes(verbose: false | undefined): Promise<resp.RemoteWithoutRefs[]>;
getRemotes(verbose: true): Promise<resp.RemoteWithRefs[]>;
/**
* Initialize a git repo
*
* @param {Boolean} [bare=false]
*/
init(bare?: boolean): Promise<void>;
/**
* List remote
*
* @param {string[]} [args]
*/
listRemote(args: string[]): Promise<string>;
/**
* Show commit logs from `HEAD` to the first commit.
* If provided between `options.from` and `options.to` tags or branch.
*
* You can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered.
*
* To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on.
*
* By default the following fields will be part of the result:
* `hash`: full commit hash
* `date`: author date, ISO 8601-like format
* `message`: subject + ref names, like the --decorate option of git-log
* `author_name`: author name
* `author_email`: author mail
* You can specify `options.format` to be an mapping from key to a format option like `%H` (for commit hash).
* The fields specified in `options.format` will be the fields in the result.
*
* Options can also be supplied as a standard options object for adding custom properties supported by the git log command.
* For any other set of options, supply options as an array of strings to be appended to the git log command.
*
* @param {LogOptions} [options]
*
* @returns Promise<ListLogSummary>
*
* @see https://git-scm.com/docs/git-log
*/
log<T = resp.DefaultLogFields>(options?: LogOptions<T>): Promise<resp.ListLogSummary<T>>;
/**
* Runs a merge, `options` can be either an array of arguments
* supported by the [`git merge`](https://git-scm.com/docs/git-merge)
* or an options object.
*
* Conflicts during the merge result in an error response,
* the response type whether it was an error or success will be a MergeSummary instance.
* When successful, the MergeSummary has all detail from a the PullSummary
*
* @param {Options | string[]} [options] options supported by [git](https://git-scm.com/docs/git-merge).
* @returns {Promise<any>}
*
* @see https://github.com/steveukx/git-js/blob/master/src/responses/MergeSummary.js
* @see https://github.com/steveukx/git-js/blob/master/src/responses/PullSummary.js
*/
merge(options: Options | string[]): Promise<MergeSummary>;
/**
* Merges from one branch to another, equivalent to running `git merge ${from} $[to}`, the `options` argument can
* either be an array of additional parameters to pass to the command or null / omitted to be ignored.
*
* @param {string} from branch to merge from.
* @param {string} to branch to merge to.
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-merge).
* @returns {Promise<string>}
*/
mergeFromTo(from: string, to: string, options?: string[]): Promise<string>;
/**
* Mirror a git repo
*
* @param {string} repoPath
* @param {string} localPath
*/
mirror(repoPath: string, localPath: string): Promise<string>;
/**
* Moves one or more files to a new destination.
*
* @see https://git-scm.com/docs/git-mv
*
* @param {string|string[]} from
* @param {string} to
*/
mv(from: string | string[], to: string): Promise<resp.MoveSummary>;
/**
* Sets a handler function to be called whenever a new child process is created, the handler function will be called
* with the name of the command being run and the stdout & stderr streams used by the ChildProcess.
*
* @example
* require('simple-git')
* .outputHandler(function (command, stdout, stderr) {
* stdout.pipe(process.stdout);
* })
* .checkout('https://github.com/user/repo.git');
*
* @see https://nodejs.org/api/child_process.html#child_process_class_childprocess
* @see https://nodejs.org/api/stream.html#stream_class_stream_readable
* @param {Function} outputHandler
*/
outputHandler(handler: outputHandler | void): this;
/**
* Fetch from and integrate with another repository or a local branch.
*
* @param {string} [remote] remote to pull from.
* @param {string} [branch] branch to pull from.
* @param {Options} [options] options supported by [git](https://git-scm.com/docs/git-pull).
* @returns {Promise<PullResult>} Parsed pull result.
*/
pull(remote?: string, branch?: string, options?: Options): Promise<PullResult>;
/**
* Update remote refs along with associated objects.
*
* @param {string} [remote] remote to push to.
* @param {string} [branch] branch to push to.
* @param {Options} [options] options supported by [git](https://git-scm.com/docs/git-push).
* @returns {Promise<void>}
*/
push(remote?: string, branch?: string, options?: Options): Promise<void>;
/**
* Pushes the current tag changes to a remote which can be either a URL or named remote. When not specified uses the
* default configured remote spec.
*
* @param {string} [remote]
*/
pushTags(remote?: string): Promise<string>;
/**
* Executes any command against the git binary.
*
* @param {string[]|Object} commands
*/
raw(commands: string | string[]): Promise<string>;
/**
* Rebases the current working copy. Options can be supplied either as an array of string parameters
* to be sent to the `git rebase` command, or a standard options object.
*
* @param {Object|String[]} [options]
*/
rebase(options?: Options | string[]): Promise<string>;
/**
* Call any `git remote` function with arguments passed as an array of strings.
*
* @param {string[]} options
*/
remote(options: string[]): Promise<void | string>;
/**
* Removes an entry from the list of remotes.
*
* @param {string} remoteName Name of the repository - eg "upstream"
* @returns {*}
*/
removeRemote(remote: string): Promise<void>;
/**
* Reset a repo
*
* @param {string|string[]} [mode=soft] Either an array of arguments supported by the 'git reset' command, or the string value 'soft' or 'hard' to set the reset mode.
*/
reset(mode?: 'soft' | 'mixed' | 'hard' | 'merge' | 'keep'): Promise<null>;
reset(commands?: string[]): Promise<void>;
/**
* Revert one or more commits in the local working copy
*
* @param {string} commit The commit to revert. Can be any hash, offset (eg: `HEAD~2`) or range (eg: `master~5..master~2`)
* @param {Object} [options] Optional options object
*/
revert(commit: String, options?: Options): Promise<void>;
/**
* Wraps `git rev-parse`. Primarily used to convert friendly commit references (ie branch names) to SHA1 hashes.
*
* Options should be an array of string options compatible with the `git rev-parse`
*
* @param {string[]} [options]
*
* @returns Promise<string>
*
* @see https://git-scm.com/docs/git-rev-parse
*/
revparse(options?: string[]): Promise<string>;
/**
* Removes the named files from source control.
*
* @param {string|string[]} files
*/
rm(paths: string | string[]): Promise<void>;
/**
* Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
* completely remove the files, use `rm`.
*
* @param {string|string[]} files
*/
rmKeepLocal(paths: string | string[]): Promise<void>;
/**
* Show various types of objects, for example the file at a certain commit
*
* @param {string[]} [options]
*/
show(options?: string[]): Promise<string>;
/**
* Disables/enables the use of the console for printing warnings and errors, by default messages are not shown in
* a production environment.
*
* @param {boolean} silence
* @returns {simplegit.SimpleGit}
*/
silent(silence?: boolean): simplegit.SimpleGit;
/**
* Stash the local repo
*
* @param {Object|Array} [options]
*/
stash(options?: Options | any[]): Promise<string>;
/**
* List the stash(s) of the local repo
*
* @param {Object|Array} [options]
*/
stashList(options?: Options | string[]): Promise<resp.ListLogSummary>;
/**
* Show the working tree status.
*
* @returns {Promise<StatusResult>} Parsed status result.
*/
status(): Promise<StatusResult>;
/**
* Call any `git submodule` function with arguments passed as an array of strings.
*
* @param {string[]} options
*/
subModule(options: string[]): Promise<string>;
/**
* Add a submodule
*
* @param {string} repo
* @param {string} path
*/
submoduleAdd(repo: string, path: string): Promise<void>;
/**
* Initialize submodules
*
* @param {string[]} [args]
*/
submoduleInit(options?: string[]): Promise<string>;
/**
* Update submodules
*
* @param {string[]} [args]
*/
submoduleUpdate(options?: string[]): Promise<string>;
/**
* List all tags. When using git 2.7.0 or above, include an options object with `"--sort": "property-name"` to
* sort the tags by that property instead of using the default semantic versioning sort.
*
* Note, supplying this option when it is not supported by your Git version will cause the operation to fail.
*
* @param {Object} [options]
*/
tag(options?: Options | string[]): Promise<string>;
/**
* Gets a list of tagged versions.
*
* @param {Options} options
* @returns {Promise<TagResult>} Parsed tag list.
*/
tags(options?: Options): Promise<TagResult>;
/**
* Updates repository server info
*/
updateServerInfo(): Promise<string>;
}
type Options = { [key: string]: null | string | any };
type LogOptions<T = resp.DefaultLogFields> = Options & {
format?: T;
file?: string;
from?: string;
multiLine?: boolean;
symmetric?: boolean;
to?: string;
};
// responses
// ---------------------
interface BranchSummary extends resp.BranchSummary {}
interface CommitSummary extends resp.CommitSummary {}
interface MergeSummary extends resp.MergeSummary {}
interface PullResult extends resp.PullResult {}
interface FetchResult extends resp.FetchResult {}
interface StatusResult extends resp.StatusResult {}
interface DiffResult extends resp.DiffResult {}
interface TagResult extends resp.TagResult {}
type outputHandler = (
command: string,
stdout: NodeJS.ReadableStream,
stderr: NodeJS.ReadableStream
) => void
}
export = simplegit;

@ -0,0 +1,96 @@
if (typeof Promise === 'undefined') {
throw new ReferenceError("Promise wrappers must be enabled to use the promise API");
}
function isAsyncCall (fn) {
return /^[^)]+then\s*\)/.test(fn) || /\._run\(/.test(fn);
}
module.exports = function (baseDir) {
var Git = require('./src/git');
var gitFactory = require('./src');
var git;
var chain = Promise.resolve();
try {
git = gitFactory(baseDir);
}
catch (e) {
chain = Promise.reject(e);
}
return Object.keys(Git.prototype).reduce(function (promiseApi, fn) {
if (/^_|then/.test(fn)) {
return promiseApi;
}
if (isAsyncCall(Git.prototype[fn])) {
promiseApi[fn] = git ? asyncWrapper(fn, git) : function () {
return chain;
};
}
else {
promiseApi[fn] = git ? syncWrapper(fn, git, promiseApi) : function () {
return promiseApi;
};
}
return promiseApi;
}, {});
function asyncWrapper (fn, git) {
return function () {
var args = [].slice.call(arguments);
if (typeof args[args.length] === 'function') {
throw new TypeError(
"Promise interface requires that handlers are not supplied inline, " +
"trailing function not allowed in call to " + fn);
}
return chain.then(function () {
return new Promise(function (resolve, reject) {
args.push(function (err, result) {
if (err) {
return reject(toError(err));
}
resolve(result);
});
git[fn].apply(git, args);
});
});
};
}
function syncWrapper (fn, git, api) {
return function () {
git[fn].apply(git, arguments);
return api;
};
}
};
function toError (error) {
if (error instanceof Error) {
return error;
}
if (typeof error === 'string') {
return new Error(error);
}
return Object.create(new Error(error), {
git: { value: error },
});
}

380
node_modules/simple-git/readme.md generated vendored

@ -0,0 +1,380 @@
# Simple Git
[![NPM version](https://img.shields.io/npm/v/simple-git.svg)](https://www.npmjs.com/package/simple-git) [![Build Status](https://travis-ci.org/steveukx/git-js.svg?branch=master)](https://travis-ci.org/steveukx/git-js)
A light weight interface for running git commands in any [node.js](https://nodejs.org) application.
# Installation
Easiest through [npm](https://npmjs.org): `npm install simple-git`
# Dependencies
Requires [git](https://git-scm.com/downloads) to be installed and that it can be called using the command `git`.
# Usage
Include into your app using:
```js
const simpleGit = require('simple-git')(workingDirPath);
```
> where the `workingDirPath` is optional, defaulting to the current directory.
Use `simpleGit` by chaining any of its functions together. Each function accepts an optional final argument which will
be called when that step has been completed. When it is called it has two arguments - firstly an error object (or null
when no error occurred) and secondly the data generated by that call.
| API | What it does |
|-----|--------------|
| `.add([fileA, ...], handlerFn)` | adds one or more files to be under source control |
| `.addAnnotatedTag(tagName, tagMessage, handlerFn)` | adds an annotated tag to the head of the current branch |
| `.addConfig(key, value[, handlerFn])` | add a local configuration property |
| `.addRemote(name, repo, handlerFn)` | adds a new named remote to be tracked as `name` at the path `repo` |
| `.addTag(name, handlerFn)` | adds a lightweight tag to the head of the current branch |
| `.branch([options, ][handlerFn])` | gets a list of all branches, calls `handlerFn` with two arguments, an error object and [BranchSummary](src/responses/BranchSummary.js) instance. When supplied, the options can be either an array of arguments supported by the [branch](https://git-scm.com/docs/git-branch) command or a standard [options](#how-to-specify-options) object. |
| `.branchLocal([handlerFn])` | gets a list of local branches, calls `handlerFn` with two arguments, an error object and [BranchSummary](src/responses/BranchSummary.js) instance |
| `.catFile(options[, handlerFn])` | generate `cat-file` detail, `options` should be an array of strings as supported arguments to the [cat-file](https://git-scm.com/docs/git-cat-file) command |
| `.checkIgnore([filepath, ...], handlerFn)` | checks if filepath excluded by .gitignore rules |
| `.checkIsRepo(handlerFn)` | Determines whether the current working directory is part of a git repository, the handler will be called with standard error object and a boolean response. |
| `.checkout(checkoutWhat, handlerFn)` | checks out the supplied tag, revision or branch. `checkoutWhat` can be one or more strings to be used as parameters appended to the `git checkout` command. |
| `.checkoutBranch(branchName, startPoint, handlerFn)` | checks out a new branch from the supplied start point |
| `.checkoutLatestTag(handlerFn)` | convenience method to pull then checkout the latest tag |
| `.checkoutLocalBranch(branchName, handlerFn)` | checks out a new local branch |
| `.clean(mode [, options [, handlerFn]])` | clean the working tree. Mode should be "n" - dry run or "f" - force |
| `.clearQueue()` | immediately clears the queue of pending tasks (note: any command currently in progress will still call its completion callback) |
| `.clone(repoPath, [localPath, [options]], [handlerFn])` | clone a remote repo at `repoPath` to a local directory at `localPath` (can be omitted to use the default of a directory with the same name as the repo name) with an optional array of additional arguments to include between `git clone` and the trailing `repo local` arguments |
| `.commit(message, handlerFn)` | commits changes in the current working directory with the supplied message where the message can be either a single string or array of strings to be passed as separate arguments (the `git` command line interface converts these to be separated by double line breaks) |
| `.commit(message, [fileA, ...], options, handlerFn)` | commits changes on the named files with the supplied message, when supplied, the optional options object can contain any other parameters to pass to the commit command, setting the value of the property to be a string will add `name=value` to the command string, setting any other type of value will result in just the key from the object being passed (ie: just `name`), an example of setting the author is below |
| `.customBinary(gitPath)` | sets the command to use to reference git, allows for using a git binary not available on the path environment variable |
| `.cwd(workingDirectory)` | Sets the current working directory for all commands after this step in the chain |
| `.deleteLocalBranch(branchName, handlerFn)` | deletes a local branch |
| `.diff(options, handlerFn)` | get the diff of the current repo compared to the last commit with a set of options supplied as a string |
| `.diff(handlerFn)` | get the diff for all file in the current repo compared to the last commit |
| `.diffSummary(handlerFn)` | gets a summary of the diff for files in the repo, uses the `git diff --stat` format to calculate changes. Handler is called with a nullable error object and an instance of the [DiffSummary](src/responses/DiffSummary.js) |
| `.diffSummary(options, handlerFn)` | includes options in the call to `diff --stat options` and returns a [DiffSummary](src/responses/DiffSummary.js) |
| `.env(name, value)` | Set environment variables to be passed to the spawned child processes, [see usage in detail below](#environment-variables). |
| `.exec(handlerFn)` | calls a simple function in the current step |
| `.fetch([options, ] handlerFn)` | update the local working copy database with changes from the default remote repo and branch, when supplied the options argument can be a standard [options object](#how-to-specify-options) either an array of string commands as supported by the [git fetch](https://git-scm.com/docs/git-fetch). On success, the returned data will be an instance of the [FetchSummary](src/responses/FetchSummary.js) |
| `.fetch(remote, branch, handlerFn)` | update the local working copy database with changes from a remote repo |
| `.fetch(handlerFn)` | update the local working copy database with changes from the default remote repo and branch |
| `.getRemotes([verbose], handlerFn)` | gets a list of the named remotes, when the verbose option is supplied as true, includes the URLs and purpose of each ref |
| `.init(bare, handlerFn)` | initialize a repository, optional `bare` parameter makes intialized repository bare |
| `.listRemote([args], handlerFn)` | lists remote repositories - there are so many optional arguments in the underlying `git ls-remote` call, just supply any you want to use as the optional `args` array of strings eg: `git.listRemote(['--heads', '--tags'], console.log.bind(console))` |
| `.log([options], handlerFn)` | list commits between `options.from` and `options.to` tags or branch (if not specified will show all history). Additionally you can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered. `options.symmetric` allows you to specify whether you want to use [symmetric revision range](https://git-scm.com/docs/gitrevisions#_dotted_range_notations) (To be compatible, by default, its value is true). For any other set of options, supply `options` as an array of strings to be appended to the `git log` command. To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on. Set `options.multiLine` to true to include a multi-line body in the output format. Options can also be supplied as a standard [options](#how-to-specify-options) object for adding custom properties supported by the [git log](https://git-scm.com/docs/git-log) command. |
| `.mergeFromTo(from, to, [[options,] handlerFn])` | merge from one branch to another, when supplied the options should be an array of additional parameters to pass into the [git merge](https://git-scm.com/docs/git-merge) command |
| `.merge(options, handlerFn)` | runs a merge, `options` can be either an array of arguments supported by the [git merge](https://git-scm.com/docs/git-merge) command or an [options](#how-to-specify-options) object. Conflicts during the merge result in an error response, the response type whether it was an error or success will be a [MergeSummary](src/responses/MergeSummary.js) instance. When successful, the MergeSummary has all detail from a the [PullSummary](src/responses/PullSummary.js) |
| `.mirror(repoPath, localPath, handlerFn])` | clone and mirror the repo to local |
| `.mv(from, to, handlerFn])` | rename or move a single file at `from` to `to`. On success the `handlerFn` will be called with a [MoveSummary](src/responses/MoveSummary.js) |
| `.mv(from, to, handlerFn])` | move all files in the `from` array to the `to` directory. On success the `handlerFn` will be called with a [MoveSummary](src/responses/MoveSummary.js) |
| `.outputHandler(handlerFn)` | attaches a handler that will be called with the name of the command being run and the `stdout` and `stderr` [readable streams](https://nodejs.org/api/stream.html#stream_class_stream_readable) created by the [child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess) running that command |
| `.pull(handlerFn)` | Pulls all updates from the default tracked repo |
| `.pull(remote, branch, handlerFn)` | pull all updates from the specified remote branch (eg 'origin'/'master') |
| `.pull(remote, branch, options, handlerFn)` | Pulls from named remote with any necessary options |
| `.push(remote, branch[, options] handlerFn)` | pushes to a named remote/branch, supports additional [options](#how-to-specify-options) from the [git push](https://git-scm.com/docs/git-push) command. |
| `.pushTags(remote, handlerFn)` | pushes tags to a named remote |
| `.raw(args[, handlerFn])` | Execute any arbitrary array of commands supported by the underlying git binary. When the git process returns a non-zero signal on exit and it printed something to `stderr`, the commmand will be treated as an error, otherwise treated as a success. |
| `.rebase([options,] handlerFn)` | Rebases the repo, `options` should be supplied as an array of string parameters supported by the [git rebase](https://git-scm.com/docs/git-rebase) command, or an object of options (see details below for option formats). |
| `.removeRemote(name, handlerFn)` | removes the named remote |
| `.reset([resetMode,] handlerFn)` | resets the repository, the optional first argument can either be an array of options supported by the `git reset` command or one of the string constants `mixed`, `hard`, or `soft`, if omitted the reset will be a soft reset to head, handlerFn: (err) |
| `.revert(commit [, options [, handlerFn]])` | reverts one or more commits in the working copy. The commit can be any regular commit-ish value (hash, name or offset such as `HEAD~2`) or a range of commits (eg: `master~5..master~2`). When supplied the [options](#how-to-specify-options) argument contain any options accepted by [git-revert](https://git-scm.com/docs/git-revert). |
| `.revparse([options], handlerFn)` | wraps git rev-parse. Primarily used to convert friendly commit references (ie branch names) to SHA1 hashes. Options should be an array of string options compatible with the [git rev-parse](https://git-scm.com/docs/git-rev-parse) |
| `.rm([fileA, ...], handlerFn)` | removes any number of files from source control |
| `.rmKeepLocal([fileA, ...], handlerFn)` | removes files from source control but leaves them on disk |
| `.silent(isSilent)` | sets whether the console should be used for logging errors (defaults to `true` when the `NODE_ENV` contains the string `prod`) |
| `.stash([options, ][ handlerFn])` | Stash the working directory, optional first argument can be an array of string arguments or [options](#how-to-specify-options) object to pass to the [git stash](https://git-scm.com/docs/git-stash) command. |
| `.stashList([options, ][handlerFn])` | Retrieves the stash list, optional first argument can be an object specifying `options.splitter` to override the default value of `;;;;`, alternatively options can be a set of arguments as supported by the `git stash list` command. |
| `.subModule(args [, handlerFn])` | Run a `git submodule` command with on or more arguments passed in as an `args` array |
| `.submoduleAdd(repo, path[, handlerFn])` | adds a new sub module |
| `.submoduleInit([args, ][handlerFn])` | inits sub modules, args should be an array of string arguments to pass to the `git submodule init` command |
| `.submoduleUpdate([args, ][handlerFn])` | updates sub modules, args should be an array of string arguments to pass to the `git submodule update` command |
| `.tag(args[], handlerFn)` | Runs any supported [git tag](https://git-scm.com/docs/git-tag) commands with arguments passed as an array of strings . |
| `.tags([options, ] handlerFn)` | list all tags, use the optional [options](#how-to-specify-options) object to set any options allows by the [git tag](https://git-scm.com/docs/git-tag) command. Tags will be sorted by semantic version number by default, for git versions 2.7 and above, use the `--sort` option to set a custom sort. |
| `.show([options], handlerFn)` | Show various types of objects, for example the file content at a certain commit. `options` is the single value string or array of string commands you want to run |
| `.status(handlerFn)` | gets the status of the current repo |
# How to Specify Options
For `.pull` or `.commit` options are included as an object, the keys of which will all be merged as trailing
arguments in the command string. When the value of the property in the options object is a `string`, that name value
pair will be included in the command string as `name=value`. For example:
```js
// results in 'git pull origin master --no-rebase'
git().pull('origin', 'master', {'--no-rebase': null})
// results in 'git pull origin master --rebase=true'
git().pull('origin', 'master', {'--rebase': 'true'})
```
# Release History
Bumped to a new major revision in the 1.x branch, now uses `ChildProcess.spawn` in place of `ChildProcess.exec` to
add escaping to the arguments passed to each of the tasks.
# Deprecated APIs
Use of these APIs is deprecated and should be avoided as support for them will be removed in future release:
`.then(func)` In versions 1.72 and below, it was possible to add a regular function call to the queue of tasks to be
run. As this name clashes with the use of Promises, in version 1.73.0 it is renamed to `.exec(fn)` and a warning will
be logged to `stdout` if `.then` is used. From version 2.0 the library will support promises without the need to wrap
or use the alternative require `require('simple-git/promise')`.
`.log([from, to], handlerFn)` list commits between `from` and `to` tags or branch, switch to supplying the revisions
as an options object instead.
# Complex Requests
When no suitable wrapper exists in the interface for creating a request, it is possible to run a command directly
using `git.raw([...], handler)`. The array of commands are passed directly to the `git` binary:
```js
const git = require('simple-git');
const path = '/path/to/repo';
git(path).raw(
[
'config',
'--global',
'advice.pushNonFastForward',
'false'
], (err, result) => {
// err is null unless this command failed
// result is the raw output of this command
});
```
# Authentication
The easiest way to supply a username / password to the remote host is to include it in the URL, for example:
```js
const USER = 'something';
const PASS = 'somewhere';
const REPO = 'github.com/username/private-repo';
const git = require('simple-git/promise');
const remote = `https://${USER}:${PASS}@${REPO}`;
git().silent(true)
.clone(remote)
.then(() => console.log('finished'))
.catch((err) => console.error('failed: ', err));
```
Be sure to enable silent mode to prevent fatal errors from being logged to stdout.
# Environment Variables
Pass one or more environment variables to the child processes spawned by `simple-git` with the `.env` method which
supports passing either an object of name=value pairs or setting a single variable at a time:
```js
const GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no";
const git = require('simple-git');
git()
.env('GIT_SSH_COMMAND', GIT_SSH_COMMAND)
.status((err, status) => { /* */ })
const gitP = require('simple-git/promise');
gitP().env({ ...process.env, GIT_SSH_COMMAND })
.status()
.then(status => { })
.catch(err => {});
```
Note - when passing environment variables into the child process, these will replace the standard `process.env`
variables, the example above creates a new object based on `process.env` but with the `GIT_SSH_COMMAND` property
added.
# TypeScript
To import with TypeScript:
```typescript
import gitP, { SimpleGit, StatusResult } from 'simple-git/promise';
const git: SimpleGit = gitP();
const status: StatusResult = await git.status();
```
# Promise and async compatible
To work with promises (either directly or as part of async/await), load the promise wrappers library:
```js
const simpleGit = require('simple-git/promise');
const git = simpleGit();
const status = await git.status();
```
Exceptions (generally recognised by the git process exiting with a non-zero status, or in some cases
like `merge` the git process exits with a successful zero code but there are conflicts in the merge)
should be handled by catching:
```js
try {
const mergeSummary = await git.merge();
console.log(`Merged ${ mergeSummary.merges.length } files`);
}
catch (err) {
// err.message - the string summary of the error
// err.stack - some stack trace detail
// err.git - where a parser was able to run, this is the parsed content
console.error(`Merge resulted in ${ err.git.conflicts.length } conflicts`);
}
```
# Response Object Revisions
| Class | Version | Change |
| ListLogLine | v1.110.0 | The default format expression used in `.log` splits ref data out of the `message` into a property of its own: `{ message: 'Some commit message (some-branch-name)' }` becomes `{ message: 'Some commit message', refs: 'some-branch-name' }` |
| ListLogLine | v1.110.0 | The commit body content is now included in the default format expression and can be used to identify the content of merge conflicts eg: `{ body: '# Conflicts:\n# some-file.txt' }` |
# Troubleshooting
### Every command returns ENOENT error message
There are a few potential reasons:
- `git` isn't available as a binary for the user running the main `node` process, custom paths to the binary can be used
with the `.customBinary(...)` api option.
- the working directory passed in to the main `simple-git` function isn't accessible, check it is read/write accessible
by the user running the `node` process.
### Log response properties are out of order
The properties of `git.log` are fetched using a `;` as a delimiter. If your commit messages use the `;` character,
supply a custom `splitter` in the options, for example: `git.log({ splitter: '|||' })`
# Examples
### async await with simple-git/promise:
```js
async function status (workingDir) {
const git = require('simple-git/promise');
let statusSummary = null;
try {
statusSummary = await git(workingDir).status();
}
catch (e) {
// handle the error
}
return statusSummary;
}
// using the async function
status(__dirname + '/some-repo').then(status => console.log(status));
```
### Initialise a git repo if necessary
```js
const gitP = require('simple-git/promise');
const git = gitP(__dirname);
git.checkIsRepo()
.then(isRepo => !isRepo && initialiseRepo(git))
.then(() => git.fetch());
function initialiseRepo (git) {
return git.init()
.then(() => git.addRemote('origin', 'https://some.git.repo'))
}
```
### Update repo and get a list of tags
```js
require('simple-git')(__dirname + '/some-repo')
.pull()
.tags((err, tags) => console.log("Latest available tag: %s", tags.latest));
// update repo and when there are changes, restart the app
require('simple-git')()
.pull((err, update) => {
if(update && update.summary.changes) {
require('child_process').exec('npm restart');
}
});
```
### Starting a new repo
```js
require('simple-git')()
.init()
.add('./*')
.commit("first commit!")
.addRemote('origin', 'https://github.com/user/repo.git')
.push('origin', 'master');
```
### push with `-u`
```js
require('simple-git')()
.add('./*')
.commit("first commit!")
.addRemote('origin', 'some-repo-url')
.push(['-u', 'origin', 'master'], () => console.log('done'));
```
### Piping to the console for long running tasks
```js
require('simple-git')()
.outputHandler((command, stdout, stderr) => {
stdout.pipe(process.stdout);
stderr.pipe(process.stderr);
})
.checkout('https://github.com/user/repo.git');
```
### Update repo and print messages when there are changes, restart the app
```js
require('simple-git')()
.exec(() => console.log('Starting pull...'))
.pull((err, update) => {
if(update && update.summary.changes) {
require('child_process').exec('npm restart');
}
})
.exec(() => console.log('pull done.'));
```
### Get a full commits list, and then only between 0.11.0 and 0.12.0 tags
```js
require('simple-git')()
.log((err, log) => console.log(log))
.log('0.11.0', '0.12.0', (err, log) => console.log(log));
```
### Set the local configuration for author, then author for an individual commit
```js
require('simple-git')()
.addConfig('user.name', 'Some One')
.addConfig('user.email', 'some@one.com')
.commit('committed as "Some One"', 'file-one')
.commit('committed as "Another Person"', 'file-two', { '--author': '"Another Person <another@person.com>"' });
```
### Get remote repositories
```js
require('simple-git')()
.listRemote(['--get-url'], (err, data) => {
if (!err) {
console.log('Remote url for repository at ' + __dirname + ':');
console.log(data);
}
});
```

1592
node_modules/simple-git/src/git.js generated vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,14 @@
var Git = require('./git');
module.exports = function (baseDir) {
var dependencies = require('./util/dependencies');
if (baseDir && !dependencies.exists(baseDir, dependencies.exists.FOLDER)) {
throw new Error("Cannot use simple-git on a directory that does not exist.");
}
return new Git(baseDir || process.cwd(), dependencies.childProcess(), dependencies.buffer());
};

@ -0,0 +1,26 @@
module.exports = BranchDeletion;
function BranchDeletion (branch, hash) {
this.branch = branch;
this.hash = hash;
this.success = hash !== null;
}
BranchDeletion.deleteSuccessRegex = /(\S+)\s+\(\S+\s([^\)]+)\)/;
BranchDeletion.deleteErrorRegex = /^error[^']+'([^']+)'/;
BranchDeletion.parse = function (data, asArray) {
var result;
var branchDeletions = data.trim().split('\n').map(function (line) {
if (result = BranchDeletion.deleteSuccessRegex.exec(line)) {
return new BranchDeletion(result[1], result[2]);
}
else if (result = BranchDeletion.deleteErrorRegex.exec(line)) {
return new BranchDeletion(result[1], null);
}
})
.filter(Boolean);
return asArray ? branchDeletions : branchDeletions.pop();
};

@ -0,0 +1,52 @@
module.exports = BranchSummary;
function BranchSummary () {
this.detached = false;
this.current = '';
this.all = [];
this.branches = {};
}
BranchSummary.prototype.push = function (current, detached, name, commit, label) {
if (current) {
this.detached = detached;
this.current = name;
}
this.all.push(name);
this.branches[name] = {
current: current,
name: name,
commit: commit,
label: label
};
};
BranchSummary.detachedRegex = /^(\*?\s+)\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/;
BranchSummary.branchRegex = /^(\*?\s+)(\S+)\s+([a-z0-9]+)\s(.*)$/;
BranchSummary.parse = function (commit) {
var branchSummary = new BranchSummary();
commit.split('\n')
.forEach(function (line) {
var detached = true;
var branch = BranchSummary.detachedRegex.exec(line);
if (!branch) {
detached = false;
branch = BranchSummary.branchRegex.exec(line);
}
if (branch) {
branchSummary.push(
branch[1].charAt(0) === '*',
detached,
branch[2],
branch[3],
branch[4]
);
}
});
return branchSummary;
};

@ -0,0 +1,60 @@
module.exports = CommitSummary;
function CommitSummary () {
this.branch = '';
this.commit = '';
this.summary = {
changes: 0,
insertions: 0,
deletions: 0
};
this.author = null;
}
var COMMIT_BRANCH_MESSAGE_REGEX = /\[([^\s]+) ([^\]]+)/;
var COMMIT_AUTHOR_MESSAGE_REGEX = /\s*Author:\s(.+)/i;
function setBranchFromCommit (commitSummary, commitData) {
if (commitData) {
commitSummary.branch = commitData[1];
commitSummary.commit = commitData[2];
}
}
function setSummaryFromCommit (commitSummary, commitData) {
if (commitSummary.branch && commitData) {
commitSummary.summary.changes = commitData[1] || 0;
commitSummary.summary.insertions = commitData[2] || 0;
commitSummary.summary.deletions = commitData[3] || 0;
}
}
function setAuthorFromCommit (commitSummary, commitData) {
var parts = commitData[1].split('<');
var email = parts.pop();
if (email.indexOf('@') <= 0) {
return;
}
commitSummary.author = {
email: email.substr(0, email.length - 1),
name: parts.join('<').trim()
};
}
CommitSummary.parse = function (commit) {
var lines = commit.trim().split('\n');
var commitSummary = new CommitSummary();
setBranchFromCommit(commitSummary, COMMIT_BRANCH_MESSAGE_REGEX.exec(lines.shift()));
if (COMMIT_AUTHOR_MESSAGE_REGEX.test(lines[0])) {
setAuthorFromCommit(commitSummary, COMMIT_AUTHOR_MESSAGE_REGEX.exec(lines.shift()));
}
setSummaryFromCommit(commitSummary, /(\d+)[^,]*(?:,\s*(\d+)[^,]*)?(?:,\s*(\d+))?/g.exec(lines.shift()));
return commitSummary;
};

@ -0,0 +1,92 @@
module.exports = DiffSummary;
/**
* The DiffSummary is returned as a response to getting `git().status()`
*
* @constructor
*/
function DiffSummary () {
this.files = [];
this.insertions = 0;
this.deletions = 0;
this.changed = 0;
}
/**
* Number of lines added
* @type {number}
*/
DiffSummary.prototype.insertions = 0;
/**
* Number of lines deleted
* @type {number}
*/
DiffSummary.prototype.deletions = 0;
/**
* Number of files changed
* @type {number}
*/
DiffSummary.prototype.changed = 0;
DiffSummary.parse = function (text) {
var line, handler;
var lines = text.trim().split('\n');
var status = new DiffSummary();
var summary = lines.pop();
if (summary) {
summary.trim().split(', ').forEach(function (text) {
var summary = /(\d+)\s([a-z]+)/.exec(text);
if (!summary) {
return;
}
if (/files?/.test(summary[2])) {
status.changed = parseInt(summary[1], 10);
}
else {
status[summary[2].replace(/s$/, '') + 's'] = parseInt(summary[1], 10);
}
});
}
while (line = lines.shift()) {
textFileChange(line, status.files) || binaryFileChange(line, status.files);
}
return status;
};
function textFileChange (line, files) {
line = line.trim().match(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/);
if (line) {
var alterations = (line[3] || '').trim();
files.push({
file: line[1].trim(),
changes: parseInt(line[2], 10),
insertions: alterations.replace(/-/g, '').length,
deletions: alterations.replace(/\+/g, '').length,
binary: false
});
return true;
}
}
function binaryFileChange (line, files) {
line = line.match(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)$/);
if (line) {
files.push({
file: line[1].trim(),
before: +line[2],
after: +line[3],
binary: true
});
return true;
}
}

@ -0,0 +1,55 @@
'use strict';
function FetchSummary (raw) {
this.raw = raw;
this.remote = null;
this.branches = [];
this.tags = [];
}
FetchSummary.parsers = [
[
/From (.+)$/, function (fetchSummary, matches) {
fetchSummary.remote = matches[0];
}
],
[
/\* \[new branch\]\s+(\S+)\s*\-> (.+)$/, function (fetchSummary, matches) {
fetchSummary.branches.push({
name: matches[0],
tracking: matches[1]
});
}
],
[
/\* \[new tag\]\s+(\S+)\s*\-> (.+)$/, function (fetchSummary, matches) {
fetchSummary.tags.push({
name: matches[0],
tracking: matches[1]
});
}
]
];
FetchSummary.parse = function (data) {
var fetchSummary = new FetchSummary(data);
String(data)
.trim()
.split('\n')
.forEach(function (line) {
var original = line.trim();
FetchSummary.parsers.some(function (parser) {
var parsed = parser[0].exec(original);
if (parsed) {
parser[1](fetchSummary, parsed.slice(1));
return true;
}
});
});
return fetchSummary;
};
module.exports = FetchSummary;

@ -0,0 +1,22 @@
'use strict';
function FileStatusSummary (path, index, working_dir) {
this.path = path;
this.index = index;
this.working_dir = working_dir;
if ('R' === index + working_dir) {
var detail = FileStatusSummary.fromPathRegex.exec(path) || [null, path, path];
this.from = detail[1];
this.path = detail[2];
}
}
FileStatusSummary.fromPathRegex = /^(.+) -> (.+)$/;
FileStatusSummary.prototype = {
path: '',
from: ''
};
module.exports = FileStatusSummary;

@ -0,0 +1,72 @@
module.exports = ListLogSummary;
var DiffSummary = require('./DiffSummary');
/**
* The ListLogSummary is returned as a response to getting `git().log()` or `git().stashList()`
*
* @constructor
*/
function ListLogSummary (all) {
this.all = all;
this.latest = all.length && all[0] || null;
this.total = all.length;
}
/**
* Detail for each of the log lines
* @type {ListLogLine[]}
*/
ListLogSummary.prototype.all = null;
/**
* Most recent entry in the log
* @type {ListLogLine}
*/
ListLogSummary.prototype.latest = null;
/**
* Number of items in the log
* @type {number}
*/
ListLogSummary.prototype.total = 0;
function ListLogLine (line, fields) {
for (var k = 0; k < fields.length; k++) {
this[fields[k]] = line[k] || '';
}
}
/**
* When the log was generated with a summary, the `diff` property contains as much detail
* as was provided in the log (whether generated with `--stat` or `--shortstat`.
* @type {DiffSummary}
*/
ListLogLine.prototype.diff = null;
ListLogSummary.START_BOUNDARY = 'òòòòòò ';
ListLogSummary.COMMIT_BOUNDARY = ' òò';
ListLogSummary.SPLITTER = ' ò ';
ListLogSummary.parse = function (text, splitter, fields) {
fields = fields || ['hash', 'date', 'message', 'refs', 'author_name', 'author_email'];
return new ListLogSummary(
text
.trim()
.split(ListLogSummary.START_BOUNDARY)
.filter(function(item) { return !!item.trim(); })
.map(function (item) {
var lineDetail = item.trim().split(ListLogSummary.COMMIT_BOUNDARY);
var listLogLine = new ListLogLine(lineDetail[0].trim().split(splitter), fields);
if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
listLogLine.diff = DiffSummary.parse(lineDetail[1]);
}
return listLogLine;
})
);
};

@ -0,0 +1,103 @@
module.exports = MergeSummary;
module.exports.MergeConflict = MergeConflict;
var PullSummary = require('./PullSummary');
function MergeConflict (reason, file, meta) {
this.reason = reason;
this.file = file;
if (meta) {
this.meta = meta;
}
}
MergeConflict.prototype.meta = null;
MergeConflict.prototype.toString = function () {
return this.file + ':' + this.reason;
};
function MergeSummary () {
PullSummary.call(this);
this.conflicts = [];
this.merges = [];
}
MergeSummary.prototype = Object.create(PullSummary.prototype);
MergeSummary.prototype.result = 'success';
MergeSummary.prototype.toString = function () {
if (this.conflicts.length) {
return 'CONFLICTS: ' + this.conflicts.join(', ');
}
return 'OK';
};
Object.defineProperty(MergeSummary.prototype, 'failed', {
get: function () {
return this.conflicts.length > 0;
}
});
MergeSummary.parsers = [
{
test: /^Auto-merging\s+(.+)$/,
handle: function (result, mergeSummary) {
mergeSummary.merges.push(result[1]);
}
},
{
// Parser for standard merge conflicts
test: /^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,
handle: function (result, mergeSummary) {
mergeSummary.conflicts.push(new MergeConflict(result[1], result[2]));
}
},
{
// Parser for modify/delete merge conflicts (modified by us/them, deleted by them/us)
test: /^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,
handle: function (result, mergeSummary) {
mergeSummary.conflicts.push(
new MergeConflict(result[1], result[2], {deleteRef: result[3]})
);
}
},
{
// Catch-all parser for unknown/unparsed conflicts
test: /^CONFLICT\s+\((.+)\):/,
handle: function (result, mergeSummary) {
mergeSummary.conflicts.push(new MergeConflict(result[1], null));
}
},
{
test: /^Automatic merge failed;\s+(.+)$/,
handle: function (result, mergeSummary) {
mergeSummary.reason = mergeSummary.result = result[1];
}
}
];
MergeSummary.parse = function (output) {
let mergeSummary = new MergeSummary();
output.trim().split('\n').forEach(function (line) {
for (var i = 0, iMax = MergeSummary.parsers.length; i < iMax; i++) {
let parser = MergeSummary.parsers[i];
var result = parser.test.exec(line);
if (result) {
parser.handle(result, mergeSummary);
break;
}
}
});
let pullSummary = PullSummary.parse(output);
if (pullSummary.summary.changes) {
Object.assign(mergeSummary, pullSummary);
}
return mergeSummary;
};

@ -0,0 +1,32 @@
module.exports = MoveSummary;
/**
* The MoveSummary is returned as a response to getting `git().status()`
*
* @constructor
*/
function MoveSummary () {
this.moves = [];
this.sources = {};
}
MoveSummary.SUMMARY_REGEX = /^Renaming (.+) to (.+)$/;
MoveSummary.parse = function (text) {
var lines = text.split('\n');
var summary = new MoveSummary();
for (var i = 0, iMax = lines.length, line; i < iMax; i++) {
line = MoveSummary.SUMMARY_REGEX.exec(lines[i].trim());
if (line) {
summary.moves.push({
from: line[1],
to: line[2]
});
}
}
return summary;
};

@ -0,0 +1,137 @@
module.exports = PullSummary;
/**
* The PullSummary is returned as a response to getting `git().pull()`
*
* @constructor
*/
function PullSummary () {
this.files = [];
this.insertions = {};
this.deletions = {};
this.summary = {
changes: 0,
insertions: 0,
deletions: 0
};
this.created = [];
this.deleted = [];
}
/**
* Array of files that were created
* @type {string[]}
*/
PullSummary.prototype.created = null;
/**
* Array of files that were deleted
* @type {string[]}
*/
PullSummary.prototype.deleted = null;
/**
* The array of file paths/names that have been modified in any part of the pulled content
* @type {string[]}
*/
PullSummary.prototype.files = null;
/**
* A map of file path to number to show the number of insertions per file.
* @type {Object}
*/
PullSummary.prototype.insertions = null;
/**
* A map of file path to number to show the number of deletions per file.
* @type {Object}
*/
PullSummary.prototype.deletions = null;
/**
* Overall summary of changes/insertions/deletions and the number associated with each
* across all content that was pulled.
* @type {Object}
*/
PullSummary.prototype.summary = null;
PullSummary.FILE_UPDATE_REGEX = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/;
PullSummary.SUMMARY_REGEX = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/;
PullSummary.ACTION_REGEX = /(create|delete) mode \d+ (.+)/;
PullSummary.parse = function (text) {
var pullSummary = new PullSummary;
var lines = text.split('\n');
while (lines.length) {
var line = lines.shift().trim();
if (!line) {
continue;
}
update(pullSummary, line) || summary(pullSummary, line) || action(pullSummary, line);
}
return pullSummary;
};
function update (pullSummary, line) {
var update = PullSummary.FILE_UPDATE_REGEX.exec(line);
if (!update) {
return false;
}
pullSummary.files.push(update[1]);
var insertions = update[2].length;
if (insertions) {
pullSummary.insertions[update[1]] = insertions;
}
var deletions = update[3].length;
if (deletions) {
pullSummary.deletions[update[1]] = deletions;
}
return true;
}
function summary (pullSummary, line) {
if (!pullSummary.files.length) {
return false;
}
var update = PullSummary.SUMMARY_REGEX.exec(line);
if (!update || (update[3] === undefined && update[5] === undefined)) {
return false;
}
pullSummary.summary.changes = +update[1] || 0;
pullSummary.summary.insertions = +update[3] || 0;
pullSummary.summary.deletions = +update[5] || 0;
return true;
}
function action (pullSummary, line) {
var match = PullSummary.ACTION_REGEX.exec(line);
if (!match) {
return false;
}
var file = match[2];
if (pullSummary.files.indexOf(file) < 0) {
pullSummary.files.push(file);
}
var container = (match[1] === 'create') ? pullSummary.created : pullSummary.deleted;
container.push(file);
return true;
}

@ -0,0 +1,188 @@
var FileStatusSummary = require('./FileStatusSummary');
module.exports = StatusSummary;
/**
* The StatusSummary is returned as a response to getting `git().status()`
*
* @constructor
*/
function StatusSummary () {
this.not_added = [];
this.conflicted = [];
this.created = [];
this.deleted = [];
this.modified = [];
this.renamed = [];
this.files = [];
this.staged = [];
}
/**
* Number of commits ahead of the tracked branch
* @type {number}
*/
StatusSummary.prototype.ahead = 0;
/**
* Number of commits behind the tracked branch
* @type {number}
*/
StatusSummary.prototype.behind = 0;
/**
* Name of the current branch
* @type {null}
*/
StatusSummary.prototype.current = null;
/**
* Name of the branch being tracked
* @type {string}
*/
StatusSummary.prototype.tracking = null;
/**
* All files represented as an array of objects containing the `path` and status in `index` and
* in the `working_dir`.
*
* @type {Array}
*/
StatusSummary.prototype.files = null;
/**
* Gets whether this StatusSummary represents a clean working branch.
*
* @return {boolean}
*/
StatusSummary.prototype.isClean = function () {
return 0 === Object.keys(this).filter(function (name) {
return Array.isArray(this[name]) && this[name].length;
}, this).length;
};
StatusSummary.parsers = {
'##': function (line, status) {
var aheadReg = /ahead (\d+)/;
var behindReg = /behind (\d+)/;
var currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
var trackingReg = /\.{3}(\S*)/;
var regexResult;
regexResult = aheadReg.exec(line);
status.ahead = regexResult && +regexResult[1] || 0;
regexResult = behindReg.exec(line);
status.behind = regexResult && +regexResult[1] || 0;
regexResult = currentReg.exec(line);
status.current = regexResult && regexResult[1];
regexResult = trackingReg.exec(line);
status.tracking = regexResult && regexResult[1];
},
'??': function (line, status) {
status.not_added.push(line);
},
A: function (line, status) {
status.created.push(line);
},
AM: function (line, status) {
status.created.push(line);
},
D: function (line, status) {
status.deleted.push(line);
},
M: function (line, status, indexState) {
status.modified.push(line);
if (indexState === 'M') {
status.staged.push(line);
}
},
R: function (line, status) {
var detail = /^(.+) -> (.+)$/.exec(line) || [null, line, line];
status.renamed.push({
from: detail[1],
to: detail[2]
});
},
UU: function (line, status) {
status.conflicted.push(line);
}
};
StatusSummary.parsers.MM = StatusSummary.parsers.M;
/* Map all unmerged status code combinations to UU to mark as conflicted */
StatusSummary.parsers.AA = StatusSummary.parsers.UU;
StatusSummary.parsers.UD = StatusSummary.parsers.UU;
StatusSummary.parsers.DU = StatusSummary.parsers.UU;
StatusSummary.parsers.DD = StatusSummary.parsers.UU;
StatusSummary.parsers.AU = StatusSummary.parsers.UU;
StatusSummary.parsers.UA = StatusSummary.parsers.UU;
StatusSummary.parse = function (text) {
var file;
var lines = text.trim().split('\n');
var status = new StatusSummary();
for (var i = 0, l = lines.length; i < l; i++) {
file = splitLine(lines[i]);
if (!file) {
continue;
}
if (file.handler) {
file.handler(file.path, status, file.index, file.workingDir);
}
if (file.code !== '##') {
status.files.push(new FileStatusSummary(file.path, file.index, file.workingDir));
}
}
return status;
};
function splitLine (lineStr) {
var line = lineStr.trim().match(/(..?)(\s+)(.*)/);
if (!line || !line[1].trim()) {
line = lineStr.trim().match(/(..?)\s+(.*)/);
}
if (!line) {
return;
}
var code = line[1];
if (line[2].length > 1) {
code += ' ';
}
if (code.length === 1 && line[2].length === 1) {
code = ' ' + code;
}
return {
raw: code,
code: code.trim(),
index: code.charAt(0),
workingDir: code.charAt(1),
handler: StatusSummary.parsers[code.trim()],
path: line[3]
};
}

@ -0,0 +1,50 @@
module.exports = TagList;
function TagList (tagList, latest) {
this.latest = latest;
this.all = tagList
}
TagList.parse = function (data, customSort) {
var number = function (input) {
if (typeof input === 'string') {
return parseInt(input.replace(/^\D+/g, ''), 10) || 0;
}
return 0;
};
var tags = data
.trim()
.split('\n')
.map(function (item) { return item.trim(); })
.filter(Boolean);
if (!customSort) {
tags.sort(function (tagA, tagB) {
var partsA = tagA.split('.');
var partsB = tagB.split('.');
if (partsA.length === 1 || partsB.length === 1) {
return tagA - tagB > 0 ? 1 : -1;
}
for (var i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
var a = number(partsA[i]);
var b = number(partsB[i]);
var diff = a - b;
if (diff) {
return diff > 0 ? 1 : -1;
}
}
return 0;
});
}
var latest = customSort ? tags[0] : tags.filter(function (tag) { return tag.indexOf('.') >= 0; }).pop();
return new TagList(tags, latest);
};

@ -0,0 +1,15 @@
module.exports = {
BranchDeleteSummary: require('./BranchDeleteSummary'),
BranchSummary: require('./BranchSummary'),
CommitSummary: require('./CommitSummary'),
DiffSummary: require('./DiffSummary'),
FetchSummary: require('./FetchSummary'),
FileStatusSummary: require('./FileStatusSummary'),
ListLogSummary: require('./ListLogSummary'),
MergeSummary: require('./MergeSummary'),
MoveSummary: require('./MoveSummary'),
PullSummary: require('./PullSummary'),
StatusSummary: require('./StatusSummary'),
TagList: require('./TagList'),
};

@ -0,0 +1,10 @@
module.exports = function deferred () {
var d = {};
d.promise = new Promise(function (resolve, reject) {
d.resolve = resolve;
d.reject = reject
});
return d;
};

@ -0,0 +1,12 @@
/**
* Exports the utilities `simple-git` depends upon to allow for mocking during a test
*/
module.exports = {
buffer: function () { return require('buffer').Buffer; },
childProcess: function () { return require('child_process'); },
exists: require('./exists')
};

@ -0,0 +1,33 @@
var fs = require('fs');
function exists (path, isFile, isDirectory) {
try {
var matches = false;
var stat = fs.statSync(path);
matches = matches || isFile && stat.isFile();
matches = matches || isDirectory && stat.isDirectory();
return matches;
}
catch (e) {
if (e.code === 'ENOENT') {
return false;
}
throw e;
}
}
module.exports = function (path, type) {
if (!type) {
return exists(path, true, true);
}
return exists(path, type & 1, type & 2);
};
module.exports.FILE = 1;
module.exports.FOLDER = 2;

@ -0,0 +1,220 @@
export interface BranchDeletionSummary {
branch: string;
hash: any;
success: boolean;
}
export interface BranchSummary {
detached: boolean;
current: string;
all: string[];
branches: {
[key: string]: {
current: boolean;
name: string;
commit: string;
label: string;
};
};
}
export interface CommitSummary {
author: null | {
email: string;
name: string;
};
branch: string;
commit: string;
summary: {
changes: number;
insertions: number;
deletions: number;
};
}
export interface DiffResultTextFile {
file: string;
changes: number;
insertions: number;
deletions: number;
binary: boolean;
}
export interface DiffResultBinaryFile {
file: string;
before: number;
after: number;
binary: boolean;
}
export interface DiffResult {
/** The total number of files changed as reported in the summary line */
changed: number;
/** When present in the diff, lists the details of each file changed */
files: Array<DiffResultTextFile | DiffResultBinaryFile>;
/** The number of files changed with insertions */
insertions: number;
/** The number of files changed with deletions */
deletions: number;
}
export interface FetchResult {
raw: string;
remote: string | null;
branches: {
name: string;
tracking: string;
}[];
tags: {
name: string;
tracking: string;
}[];
}
export interface MoveSummary {
moves: any[];
}
export interface PullResult {
/** Array of all files that are referenced in the pull */
files: string[];
/** Map of file names to the number of insertions in that file */
insertions: { [key: string]: number };
/** Map of file names to the number of deletions in that file */
deletions: any;
summary: {
changes: number;
insertions: number;
deletions: number;
};
/** Array of file names that have been created */
created: string[];
/** Array of file names that have been deleted */
deleted: string[];
}
export interface RemoteWithoutRefs {
name: string;
}
export interface RemoteWithRefs extends RemoteWithoutRefs {
refs: {
fetch: string;
push: string;
};
}
export interface StatusResultRenamed {
from: string;
to: string;
}
export interface FileStatusSumary {
/* Path of the file */
path: string;
/* First digit of the status code of the file, e.g. 'M' = modified.
Represents the status of the index if no merge conflicts, otherwise represents
status of one side of the merge. */
index: string;
/* Second digit of the status code of the file. Represents status of the working directory
if no merge conflicts, otherwise represents status of other side of a merge. */
working_dir: string;
}
export interface StatusResult {
not_added: string[];
conflicted: string[];
created: string[];
deleted: string[];
modified: string[];
renamed: StatusResultRenamed[];
staged: string[];
files: FileStatusSumary[];
ahead: number;
behind: number;
current: string;
tracking: string;
/**
* Gets whether this represents a clean working branch.
*/
isClean(): boolean;
}
export interface TagResult {
all: string[];
latest: string;
}
export interface DefaultLogFields {
hash: string;
date: string;
message: string;
refs: string;
body: string;
author_name: string;
author_email: string;
}
/**
* The ListLogLine represents a single entry in the `git.log`, the properties on the object
* are mixed in depending on the names used in the format (see `DefaultLogFields`), but some
* properties are dependent on the command used.
*/
export interface ListLogLine {
/**
* When using a `--stat=4096` or `--shortstat` options in the `git.log` or `git.stashList`,
* each entry in the `ListLogSummary` will also have a `diff` property representing as much
* detail as was given in the response.
*/
diff?: DiffResult;
}
export interface ListLogSummary<T = DefaultLogFields> {
all: ReadonlyArray<T & ListLogLine>;
total: number;
latest: T & ListLogLine;
}
/**
* Where the file was deleted, if there is a modify/delete conflict
*/
export interface MergeConflictDeletion {
deleteRef: string;
}
/**
* Represents a single file with conflicts in the MergeSummary
*/
export interface MergeConflict {
/**
* Type of conflict
*/
reason: string;
/**
* Path to file
*/
file: string;
/**
* Additional detail for the specific type of conflict
*/
meta?: MergeConflictDeletion;
}
export interface MergeSummary extends PullResult {
conflicts: MergeConflict[];
merges: string[];
result: "success" | string;
failed: boolean;
}
Loading…
Cancel
Save