diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index bbf1d1fa..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: CI - -on: [push] - -jobs: - Build: - runs-on: ubuntu-latest - env: - CC: clang - CXX: clang++ - npm_config_clang: 1 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 14 - - name: Install - run: | - npm run prepare - npm install - - name: Test - run: | - npm run lint - npm run test diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 28bf3dea..00000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/node_modules -/build -/deps/libgit2/.npmignore -/lib/*.js -*.log -*~ -.node-version diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fff038fe..00000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "deps/libgit2"] - path = deps/libgit2 - url = https://github.com/libgit2/libgit2.git - ignore = untracked diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 338b1395..00000000 --- a/.npmignore +++ /dev/null @@ -1,15 +0,0 @@ -/build -/spec -/deps/libgit2/build -/deps/libgit2/fuzzers -/deps/libgit2/tests -/deps/libgit2/tests-clar -*.a -*.o -*.coffee -*.log -*~ -.travis.yml -.node-version -.npmignore -.gitmodules diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 493db50e..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2013 GitHub Inc. - -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. diff --git a/README.md b/README.md deleted file mode 100644 index 91a2765d..00000000 --- a/README.md +++ /dev/null @@ -1,374 +0,0 @@ -##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/) - # Git Node module [![CI](https://github.com/atom/git-utils/actions/workflows/ci.yml/badge.svg)](https://github.com/atom/git-utils/actions/workflows/ci.yml) - - -Helpers for working with Git repositories built natively on top of -[libgit2](http://libgit2.github.com). - -## Installing - -```sh -npm install git-utils -``` - -## Development - * Clone the repository - * Run `npm run prepare` to get the submodule - * Run `npm install` - * Run `npm test` to run the specs - -## Docs - -### git.open(path, [search = true]) - -Open the repository at the given path. This will return `null` if the -repository at the given path does not exist or cannot be opened. - -`path` - The path from which to try to open a repository -`search` - Set to false if we shouldn't search up in the directory tree - -```coffeescript -git = require 'git-utils' - -repository = git.open('/Users/me/repos/node') -``` - -The opened repository will have a `submodules` property that will be an object -of paths mapped to submodule {Repository} objects. The path keys will be -relative to the opened repository's working directory. - -If search is set to true (the default), all paths up to the filesystem root will -be recursively checked to try and find the root directory of a repository. If a -search is false, traversing not be performed, and a repository will only be -returned if the given path is the root of a repository. - -### Repository.checkoutHead(path) - -Restore the contents of a path in the working directory and index to the -version at HEAD. Similar to running `git reset HEAD -- ` and then a -`git checkout HEAD -- `. - -`path` - The string repository-relative path to checkout. - -Returns `true` if the checkout was successful, `false` otherwise. - -### Repository.checkoutReference(reference, [create]) - -Checks out a branch in your repository. - -`reference` - The string reference to checkout -`create` - A Boolean value which, if `true` creates the new `reference` if it doesn't exist. - -Returns `true` if the checkout was successful, `false` otherwise. - -### Repository.getAheadBehindCount(branch) - -Get the number of commits the branch is ahead/behind the remote branch it -is tracking. Similar to the commit numbers reported by `git status` when a -remote tracking branch exists. - -`branch` - The branch name to lookup ahead/behind counts for. (default: `HEAD`) - -Returns an object with `ahead` and `behind` keys pointing to integer values -that will always be >= 0. - -### Repository.getCommitCount(fromCommit, toCommit) - -Get the number of commits between `fromCommit` and `toCommit`. - -`fromCommit` - The string commit SHA-1 to start the rev walk at. - -`toCommit` - The string commit SHA-1 to end the rev walk at. - -Returns the number of commits between the two, always >= 0. - -### Repository.getConfigValue(key) - -Get the config value of the given key. - -`key` - The string key to retrieve the value for. - -Returns the configuration value, may be `null`. - -### Repository.setConfigValue(key, value) - -Get the config value of the given key. - -`key` - The string key to set in the config. - -`value` - The string value to set in the config for the given key. - -Returns `true` if setting the config value was successful, `false` otherwise. - -### Repository.getDiffStats(path) - -Get the number of lines added and removed comparing the working directory -contents of the given path to the HEAD version of the given path. - -`path` - The string repository-relative path to diff. - -Returns an object with `added` and `deleted` keys pointing to integer values -that always be >= 0. - -### Repository.getHeadBlob(path) - -Get the blob contents of the given path at HEAD. Similar to -`git show HEAD:`. - -`path` - The string repository-relative path. - -Returns the string contents of the HEAD version of the path. - -### Repository.getHead() - -Get the reference or SHA-1 that HEAD points to such as `refs/heads/master` -or a full SHA-1 if the repository is in a detached HEAD state. - -Returns the string reference name or SHA-1. - -### Repository.getIndexBlob(path) - -Get the blob contents of the given path in the index. Similar to -`git show :`. - -`path` - The string repository-relative path. - -Returns the string contents of the index version of the path. - -### Repository.getLineDiffs(path, text, [options]) - -Get the line diffs comparing the HEAD version of the given path and the given -text. - -`path` - The string repository-relative path. - -`text` - The string text to diff the HEAD contents of the path against. - -`options` - An optional object with the following keys: - - * `ignoreSpaceAtEOL` - `true` to ignore changes in whitespace at the end of lines. - (ignoreEolWhitespace also works.) - * `ignoreSpaceChange` - `true` to ignore changes in amount of whitespace. - This ignores whitespace at line end, and considers all other sequences of - one or more whitespace characters to be equivalent. - * `ignoreAllSpace` - `true` to ignore whitespace when comparing lines. - This ignores differences even if one line has whitespace where the other line has none. - * `useIndex` - `true` to compare against the index version instead of the HEAD - version. - -Returns an array of objects that have `oldStart`, `oldLines`, `newStart`, and -`newLines` keys pointing to integer values, may be `null` if the diff fails. - -### Repository.getLineDiffDetails(path, text, [options]) - -Get the line diff details comparing the HEAD version of the given path and the given -text. - -Takes the same arguments as `getLineDiffs`. - -Returns an array of objects which represent an old or new line in a diff. Every -object has `oldStart`, `oldLines`, `newStart`, `newLines`, `oldLineNumber` and -`newLineNumber` keys pointing to integer values, and a `line` key pointing to the -respective line content. May be `null` if the diff fails. - -### Repository.getMergeBase(commit1, commit2) - -Get the merge base of two commits. - -`commit1` - The string SHA-1 of the first commit. - -`commit2` - The string SHA-1 of the second commit. - -Returns the string SHA-1 of the merge base of `commit1` and `commit2` or `null` -if there isn't one. - -### Repository.getPath() - -Get the path of the repository. - -Returns the string absolute path of the opened repository. - -### Repository.getReferences() - -Gets all the local and remote references. - -Returns an object with three keys: `heads`, `remotes`, and `tags`. -Each key can be an array of strings containing the reference names. - -### Repository.getReferenceTarget(ref) - -Get the target of the given reference. - -`ref` - The string reference. - -Returns the string target of the given reference. - -### Repository.getShortHead() - -Get a possibly shortened version of value returns by `getHead()`. This will -remove leading segments of `refs/heads`, `refs/tags`, or `refs/remotes` and will -also shorten the SHA-1 of a detached HEAD to 7 characters. - -Returns a string shortened reference name or SHA-1. - -### Repository.getStatus([path]) - -Get the status of a single path or all paths in the repository. This will not -include ignored paths. - -`path` - An optional repository-relative path to limit the status reporting to. - -Returns an integer status number if a path is specified and returns an object -with path keys and integer status values if no path is specified. - -### Repository.getUpstreamBranch([branch]) - -Get the upstream branch of the given branch. - -`branch` - The branch to find the upstream branch of (default: `HEAD`) - -Returns the string upstream branch reference name. - -### Repository.getWorkingDirectory() - -Get the working directory of the repository. - -Returns the string absolute path to the repository's working directory. - -### Repository.isIgnored(path) - -Get the ignored status of a given path. - -`path` - The string repository-relative path. - -Returns `true` if the path is ignored, `false` otherwise. - -### Repository.isPathModified(path) - -Get the modified status of a given path. - -`path` - The string repository-relative path. - -Returns `true` if the path is modified, `false` otherwise. - -### Repository.isPathNew(path) - -Get the new status of a given path. - -`path` - The string repository-relative path. - -Returns `true` if the path is new, `false` otherwise. - -### Repository.isPathDeleted(path) - -Get the deleted status of a given path. - -`path` - The string repository-relative path. - -Returns `true` if the path is deleted, `false` otherwise. - -### Repository.isPathStaged(path) - -Get the staged status of a given path. - -`path` - The string repository-relative path. - -Returns `true` if the path is staged in the index, `false` otherwise. - -### Repository.isStatusIgnored(status) - -Check if a status value represents an ignored path. - -`status` - The integer status value. - -Returns `true` if the status is a ignored one, `false` otherwise. - -### Repository.isStatusModified(status) - -Check if a status value represents a modified path. - -`status` - The integer status value. - -Returns `true` if the status is a modified one, `false` otherwise. - -### Repository.isStatusNew(status) - -Check if a status value represents a new path. - -`status` - The integer status value. - -Returns `true` if the status is a new one, `false` otherwise. - -### Repository.isStatusDeleted(status) - -Check if a status value represents a deleted path. - -`status` - The integer status value. - -Returns `true` if the status is a deleted one, `false` otherwise. - -### Repository.isStatusStaged(status) - -Check if a status value represents a changed that is staged in the index. - -`status` - The integer status value. - -Returns `true` if the status is a staged one, `false` otherwise. - -### Repository.isSubmodule(path) - -Check if the path is a submodule in the index. - -`path` - The string repository-relative path. - -Returns `true` if the path is a submodule, `false` otherwise. - -### Repository.refreshIndex() - -Reread the index to update any values that have changed since the last time the -index was read. - -### Repository.relativize(path) - -Relativize the given path to the repository's working directory. - -`path` - The string path to relativize. - -Returns a repository-relative path if the given path is prefixed with the -repository's working directory path. - -### Repository.isWorkingDirectory(path) - -Is the given path the repository's working directory? - -It is better to call this method than comparing a path directly against -the value of `getWorkingDirectory()` since this method handles slash -normalization on Windows, case insensitive filesystems, and symlinked -repositories. - -`path` - The string path to check. - -Returns `true` if the given path is the repository's working directory, -false otherwise. - -### Repository.release() - -Release the repository and close all file handles it has open. No other methods -can be called on the `Repository` object once it has been released. - -### Repository.submoduleForPath(path) - -Get the repository for the submodule that the path is located in. - -`path` - The absolute or repository-relative string path. - -Returns a `Repository` or `null` if the path isn't in a submodule. - -### Repository.add(path) - -Stage the changes in `path` into the repository's index. Clear any conflict state -associated with `path`. - -`path` - A repository-relative string path. - -Raises an `Error` if the path isn't readable or if another exception occurs. diff --git a/binding.gyp b/binding.gyp deleted file mode 100644 index 71fafacd..00000000 --- a/binding.gyp +++ /dev/null @@ -1,576 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'git', - 'dependencies': [ - 'libgit2' - ], - 'include_dirs': [ ' + + + + + git-utils by atom + + + + + + + +
+
+

git-utils

+

Native Git Node Module

+ +

View the Project on GitHub atom/git-utils

+ + + +
+
+

+Git Node module Build Status +

+ +

Helpers for working with Git repositories built natively on top of +libgit2.

+ +

+Installing

+ +
npm install git-utils
+
+ +

+Building

+ +
    +
  • Clone the repository with the --recurse option to get the libgit2 +submodule
  • +
  • Run npm install +
  • +
  • Run grunt to compile the native and CoffeeScript code
  • +
  • Run grunt test to run the specs
  • +

+Docs

+ +

+git.open(path)

+ +

Open the repository at the given path. This will return null if the +repository at the given path does not exist or cannot be opened.

+ +
git = require 'git-utils'
+
+repository = git.open('/Users/me/repos/node')
+
+ +

The opened repository will have a submodules property that will be an object +of paths mapped to submodule {Repository} objects. The path keys will be +relative to the opened repository's working directory.

+ +

+Repository.checkoutHead(path)

+ +

Restore the contents of a path in the working directory and index to the +version at HEAD. Similar to running git reset HEAD -- <path> and then a +git checkout HEAD -- <path>.

+ +

path - The string repository-relative path to checkout.

+ +

Returns true if the checkout was successful, false otherwise.

+ +

+Repository.checkoutReference(reference, [create])

+ +

Checks out a branch in your repository.

+ +

reference - The string reference to checkout +create - A Boolean value which, if true creates the new reference if it doesn't exist.

+ +

Returns true if the checkout was successful, false otherwise.

+ +

+Repository.getAheadBehindCount(branch)

+ +

Get the number of commits the branch is ahead/behind the remote branch it +is tracking. Similar to the commit numbers reported by git status when a +remote tracking branch exists.

+ +

branch - The branch name to lookup ahead/behind counts for. (default: HEAD)

+ +

Returns an object with ahead and behind keys pointing to integer values +that will always be >= 0.

+ +

+Repository.getCommitCount(fromCommit, toCommit)

+ +

Get the number of commits between fromCommit and toCommit.

+ +

fromCommit - The string commit SHA-1 to start the rev walk at.

+ +

toCommit - The string commit SHA-1 to end the rev walk at.

+ +

Returns the number of commits between the two, always >= 0.

+ +

+Repository.getConfigValue(key)

+ +

Get the config value of the given key.

+ +

key - The string key to retrieve the value for.

+ +

Returns the configuration value, may be null.

+ +

+Repository.setConfigValue(key, value)

+ +

Get the config value of the given key.

+ +

key - The string key to set in the config.

+ +

value - The string value to set in the config for the given key.

+ +

Returns true if setting the config value was successful, false otherwise.

+ +

+Repository.getDiffStats(path)

+ +

Get the number of lines added and removed comparing the working directory +contents of the given path to the HEAD version of the given path.

+ +

path - The string repository-relative path to diff.

+ +

Returns an object with added and deleted keys pointing to integer values +that always be >= 0.

+ +

+Repository.getHeadBlob(path)

+ +

Get the blob contents of the given path at HEAD. Similar to +git show HEAD:<path>.

+ +

path - The string repository-relative path.

+ +

Returns the string contents of the HEAD version of the path.

+ +

+Repository.getHead()

+ +

Get the reference or SHA-1 that HEAD points to such as refs/heads/master +or a full SHA-1 if the repository is in a detached HEAD state.

+ +

Returns the string reference name or SHA-1.

+ +

+Repository.getIndexBlob(path)

+ +

Get the blob contents of the given path in the index. Similar to +git show :<path>.

+ +

path - The string repository-relative path.

+ +

Returns the string contents of the index version of the path.

+ +

+Repository.getLineDiffs(path, text, [options])

+ +

Get the line diffs comparing the HEAD version of the given path and the given +text.

+ +

path - The string repository-relative path.

+ +

text - The string text to diff the HEAD contents of the path against.

+ +

options - An optional object with the following keys:

+ +
    +
  • +ignoreEolWhitespace - true to ignore any whitespace diffs at the end of +lines.
  • +
  • +useIndex - true to compare against the index version instead of the HEAD +version.
  • +

Returns an array of objects that have oldStart, oldLines, newStart, and +newLines keys pointing to integer values, may be null if the diff fails.

+ +

+Repository.getMergeBase(commit1, commit2)

+ +

Get the merge base of two commits.

+ +

commit1 - The string SHA-1 of the first commit.

+ +

commit2 - The string SHA-1 of the second commit.

+ +

Returns the string SHA-1 of the merge base of commit1 and commit2 or null +if there isn't one.

+ +

+Repository.getPath()

+ +

Get the path of the repository.

+ +

Returns the string absolute path of the opened repository.

+ +

+Repository.getReferences()

+ +

Gets all the local and remote references.

+ +

Returns an object with three keys: heads, remotes, and tags. +Each key can be an array of strings containing the reference names.

+ +

+Repository.getReferenceTarget(ref)

+ +

Get the target of the given reference.

+ +

ref - The string reference.

+ +

Returns the string target of the given reference.

+ +

+Repository.getShortHead()

+ +

Get a possibly shortened version of value returns by getHead(). This will +remove leading segments of refs/heads, refs/tags, or refs/remotes and will +also shorten the SHA-1 of a detached HEAD to 7 characters.

+ +

Returns a string shortened reference name or SHA-1.

+ +

+Repository.getStatus([path])

+ +

Get the status of a single path or all paths in the repository. This will not +include ignored paths.

+ +

path - An optional repository-relative path to limit the status reporting to.

+ +

Returns an integer status number if a path is specified and returns an object +with path keys and integer status values if no path is specified.

+ +

+Repository.getUpstreamBranch([branch])

+ +

Get the upstream branch of the given branch.

+ +

branch - The branch to find the upstream branch of (default: HEAD)

+ +

Returns the string upstream branch reference name.

+ +

+Repository.getWorkingDirectory()

+ +

Get the working directory of the repository.

+ +

Returns the string absolute path to the repository's working directory.

+ +

+Repository.isIgnored(path)

+ +

Get the ignored status of a given path.

+ +

path - The string repository-relative path.

+ +

Returns true if the path is ignored, false otherwise.

+ +

+Repository.isPathModified(path)

+ +

Get the modified status of a given path.

+ +

path - The string repository-relative path.

+ +

Returns true if the path is modified, false otherwise.

+ +

+Repository.isPathNew(path)

+ +

Get the new status of a given path.

+ +

path - The string repository-relative path.

+ +

Returns true if the path is new, false otherwise.

+ +

+Repository.isPathDeleted(path)

+ +

Get the deleted status of a given path.

+ +

path - The string repository-relative path.

+ +

Returns true if the path is deleted, false otherwise.

+ +

+Repository.isStatusIgnored(status)

+ +

Check if a status value represents an ignored path.

+ +

status - The integer status value.

+ +

Returns true if the status is a ignored one, false otherwise.

+ +

+Repository.isStatusModified(status)

+ +

Check if a status value represents a modified path.

+ +

status - The integer status value.

+ +

Returns true if the status is a modified one, false otherwise.

+ +

+Repository.isStatusNew(status)

+ +

Check if a status value represents a new path.

+ +

status - The integer status value.

+ +

Returns true if the status is a new one, false otherwise.

+ +

+Repository.isStatusDeleted(status)

+ +

Check if a status value represents a deleted path.

+ +

status - The integer status value.

+ +

Returns true if the status is a deleted one, false otherwise.

+ +

+Repository.isSubmodule(path)

+ +

Check if the path is a submodule in the index.

+ +

path - The string repository-relative path.

+ +

Returns true if the path is a submodule, false otherwise.

+ +

+Repository.refreshIndex()

+ +

Reread the index to update any values that have changed since the last time the +index was read.

+ +

+Repository.relativize(path)

+ +

Relativize the given path to the repository's working directory.

+ +

path - The string path to relativize.

+ +

Returns a repository-relative path if the given path is prefixed with the +repository's working directory path.

+ +

+Repository.isWorkingDirectory(path)

+ +

Is the given path the repository's working directory?

+ +

It is better to call this method than comparing a path directly against +the value of getWorkingDirectory() since this method handles slash +normalization on Windows, case insensitive filesystems, and symlinked +repositories.

+ +

path - The string path to check.

+ +

Returns true if the given path is the repository's working directory, +false otherwise.

+ +

+Repository.release()

+ +

Release the repository and close all file handles it has open. No other methods +can be called on the Repository object once it has been released.

+ +

+Repository.submoduleForPath(path)

+ +

Get the repository for the submodule that the path is located in.

+ +

path - The absolute or repository-relative string path.

+ +

Returns a Repository or null if the path isn't in a submodule.

+ +

+Repository.add(path)

+ +

Stage the changes in path into the repository's index. Clear any conflict state +associated with path.

+ +

path - A repository-relative string path.

+ +

Raises an Error if the path isn't readable or if another exception occurs.

+
+
+

This project is maintained by atom

+

Hosted on GitHub Pages — Theme by orderedlist

+
+
+ + + + \ No newline at end of file diff --git a/javascripts/scale.fix.js b/javascripts/scale.fix.js new file mode 100644 index 00000000..87a40ca7 --- /dev/null +++ b/javascripts/scale.fix.js @@ -0,0 +1,17 @@ +var metas = document.getElementsByTagName('meta'); +var i; +if (navigator.userAgent.match(/iPhone/i)) { + for (i=0; i=1.0.1", - "coffeestack": ">=1 <2", - "gaze": "~0.3.2", - "jasmine-reporters": ">=0.2.0", - "mkdirp": "~0.3.5", - "requirejs": ">=0.27.1", - "underscore": ">= 1.3.1", - "walkdir": ">= 0.0.1" - }, - "dependencies": { - "mkdirp": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", - "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=", - "dev": true - } - } - }, - "jasmine-reporters": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/jasmine-reporters/-/jasmine-reporters-2.3.2.tgz", - "integrity": "sha512-u/7AT9SkuZsUfFBLLzbErohTGNsEUCKaQbsVYnLFW1gEuL2DzmBL4n8v90uZsqIqlWvWUgian8J6yOt5Fyk/+A==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1", - "xmldom": "^0.1.22" - } - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "~0.0.0" - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonpointer": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.1.0.tgz", - "integrity": "sha512-CXcRvMyTlnR53xMcKnuMzfCA5i/nfblTnnr74CZb6C4vG39eu6w51t7nKmU5MfLfbTgGItliNyjO/ciNPDqClg==", - "dev": true - }, - "jsx-ast-utils": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", - "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=", - "dev": true - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, - "lodash.cond": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", - "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", - "dev": true - }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", - "dev": true - }, - "nan": { - "version": "2.14.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", - "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", - "dev": true - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "object-inspect": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz", - "integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==", - "dev": true - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "^2.0.0" - } - }, - "pkg-conf": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-2.1.0.tgz", - "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", - "dev": true, - "requires": { - "find-up": "^2.0.0", - "load-json-file": "^4.0.0" - } - }, - "pkg-config": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pkg-config/-/pkg-config-1.1.1.tgz", - "integrity": "sha1-VX7yLXPaPIg3EHdmxS6tq94pj+Q=", - "dev": true, - "requires": { - "debug-log": "^1.0.0", - "find-root": "^1.0.0", - "xtend": "^4.0.1" - } - }, - "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", - "dev": true, - "requires": { - "find-up": "^2.1.0" - } - }, - "pkg-up": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-1.0.0.tgz", - "integrity": "sha1-Pgj7RhUlxEIWJKM7n35tCvWwWiY=", - "dev": true, - "requires": { - "find-up": "^1.0.0" - }, - "dependencies": { - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - } - } - }, - "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", - "dev": true - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "mute-stream": "0.0.5" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "^1.1.6" - } - }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - } - }, - "requirejs": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", - "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", - "dev": true - }, - "resolve": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", - "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", - "dev": true, - "requires": { - "is-core-module": "^2.1.0", - "path-parse": "^1.0.6" - } - }, - "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" - } - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", - "dev": true, - "requires": { - "once": "^1.3.0" - } - }, - "run-parallel": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", - "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", - "dev": true - }, - "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "semver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", - "dev": true - }, - "shelljs": { - "version": "0.7.8", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", - "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", - "dev": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - } - }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true - }, - "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true - }, - "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "requires": { - "amdefine": ">=0.0.4" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "standard": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/standard/-/standard-10.0.3.tgz", - "integrity": "sha512-JURZ+85ExKLQULckDFijdX5WHzN6RC7fgiZNSV4jFQVo+3tPoQGHyBrGekye/yf0aOfb4210EM5qPNlc2cRh4w==", - "dev": true, - "requires": { - "eslint": "~3.19.0", - "eslint-config-standard": "10.2.1", - "eslint-config-standard-jsx": "4.0.2", - "eslint-plugin-import": "~2.2.0", - "eslint-plugin-node": "~4.2.2", - "eslint-plugin-promise": "~3.5.0", - "eslint-plugin-react": "~6.10.0", - "eslint-plugin-standard": "~3.0.1", - "standard-engine": "~7.0.0" - } - }, - "standard-engine": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-7.0.0.tgz", - "integrity": "sha1-67d7nI/CyBZf+jU72Rug3/Qa9pA=", - "dev": true, - "requires": { - "deglob": "^2.1.0", - "get-stdin": "^5.0.1", - "minimist": "^1.1.0", - "pkg-conf": "^2.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string.prototype.trimend": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz", - "integrity": "sha512-ayH0pB+uf0U28CtjlLvL7NaohvR1amUvVZk+y3DYb0Ey2PUV5zPkkKy9+U1ndVEIXO8hNg18eIv9Jntbii+dKw==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" - } - }, - "string.prototype.trimstart": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.3.tgz", - "integrity": "sha512-oBIBUy5lea5tt0ovtOFiEQaBkoBBkyJhZXzJYrSmDo5IUUqbOPvVezuRs/agBIdZ2p2Eo1FD6bD9USyBLfl3xg==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", - "dev": true, - "requires": { - "ajv": "^4.7.0", - "ajv-keywords": "^1.0.0", - "chalk": "^1.1.1", - "lodash": "^4.0.0", - "slice-ansi": "0.0.4", - "string-width": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, - "temp": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", - "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1", - "rimraf": "~2.6.2" - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "underscore": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.5.2.tgz", - "integrity": "sha1-EzXF5PXm0zu7SwBrqMhqAPVW3gg=", - "dev": true - }, - "underscore-plus": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore-plus/-/underscore-plus-1.7.0.tgz", - "integrity": "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA==", - "dev": true, - "requires": { - "underscore": "^1.9.1" - }, - "dependencies": { - "underscore": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.0.tgz", - "integrity": "sha512-21rQzss/XPMjolTiIezSu3JAjgagXKROtNrYFEOWK109qY1Uv2tVjPTZ1ci2HgvQDA16gHYSthQIJfB+XId/rQ==", - "dev": true - } - } - }, - "uniq": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", - "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", - "dev": true - }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", - "dev": true, - "requires": { - "os-homedir": "^1.0.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "walkdir": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/walkdir/-/walkdir-0.0.7.tgz", - "integrity": "sha1-BNoCcKh6d4VAFzzb8KLbSZqNnik=", - "dev": true - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "wrench": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/wrench/-/wrench-1.4.4.tgz", - "integrity": "sha1-f1I+/bcbAQDnfc6DTAZSPL49VOA=", - "dev": true - }, - "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, - "xmldom": { - "version": "0.1.31", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz", - "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==", - "dev": true - }, - "xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 2d6a9e1e..00000000 --- a/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "git-utils", - "description": "A package for using Git repositories", - "version": "5.7.3", - "license": "MIT", - "author": { - "name": "Kevin Sawicki", - "email": "kevin@github.com" - }, - "contributors": [ - { - "name": "Garen J. Torikian", - "email": "gjtorikian@gmail.com" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/atom/git-utils.git" - }, - "bugs": { - "url": "https://github.com/atom/git-utils/issues" - }, - "homepage": "http://atom.github.io/git-utils", - "keywords": [ - "git", - "libgit2", - "dvcs", - "vcs" - ], - "main": "./src/git.js", - "devDependencies": { - "jasmine-focused": "^1.0.4", - "standard": "^10.0.3", - "temp": "~0.9.4", - "underscore": "~1.5.2", - "wrench": "~1.4.4" - }, - "dependencies": { - "fs-plus": "^3.0.0", - "nan": "^2.14.2" - }, - "scripts": { - "lint": "standard src spec", - "test": "jasmine-focused --captureExceptions spec", - "prepare": "git submodule update --init --recursive" - } -} diff --git a/params.json b/params.json new file mode 100644 index 00000000..f24ab74d --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"git-utils","tagline":"Native Git Node Module","body":"# Git Node module [![Build Status](https://travis-ci.org/atom/git-utils.svg?branch=master)](https://travis-ci.org/atom/git-utils)\r\n\r\nHelpers for working with Git repositories built natively on top of\r\n[libgit2](http://libgit2.github.com).\r\n\r\n## Installing\r\n\r\n```sh\r\nnpm install git-utils\r\n```\r\n\r\n## Building\r\n * Clone the repository with the `--recurse` option to get the libgit2\r\n submodule\r\n * Run `npm install`\r\n * Run `grunt` to compile the native and CoffeeScript code\r\n * Run `grunt test` to run the specs\r\n\r\n## Docs\r\n\r\n### git.open(path)\r\n\r\nOpen the repository at the given path. This will return `null` if the\r\nrepository at the given path does not exist or cannot be opened.\r\n\r\n```coffeescript\r\ngit = require 'git-utils'\r\n\r\nrepository = git.open('/Users/me/repos/node')\r\n```\r\n\r\nThe opened repository will have a `submodules` property that will be an object\r\nof paths mapped to submodule {Repository} objects. The path keys will be\r\nrelative to the opened repository's working directory.\r\n\r\n### Repository.checkoutHead(path)\r\n\r\nRestore the contents of a path in the working directory and index to the\r\nversion at HEAD. Similar to running `git reset HEAD -- ` and then a\r\n`git checkout HEAD -- `.\r\n\r\n`path` - The string repository-relative path to checkout.\r\n\r\nReturns `true` if the checkout was successful, `false` otherwise.\r\n\r\n### Repository.checkoutReference(reference, [create])\r\n\r\nChecks out a branch in your repository.\r\n\r\n`reference` - The string reference to checkout\r\n`create` - A Boolean value which, if `true` creates the new `reference` if it doesn't exist.\r\n\r\nReturns `true` if the checkout was successful, `false` otherwise.\r\n\r\n### Repository.getAheadBehindCount(branch)\r\n\r\nGet the number of commits the branch is ahead/behind the remote branch it\r\nis tracking. Similar to the commit numbers reported by `git status` when a\r\nremote tracking branch exists.\r\n\r\n`branch` - The branch name to lookup ahead/behind counts for. (default: `HEAD`)\r\n\r\nReturns an object with `ahead` and `behind` keys pointing to integer values\r\nthat will always be >= 0.\r\n\r\n### Repository.getCommitCount(fromCommit, toCommit)\r\n\r\nGet the number of commits between `fromCommit` and `toCommit`.\r\n\r\n`fromCommit` - The string commit SHA-1 to start the rev walk at.\r\n\r\n`toCommit` - The string commit SHA-1 to end the rev walk at.\r\n\r\nReturns the number of commits between the two, always >= 0.\r\n\r\n### Repository.getConfigValue(key)\r\n\r\nGet the config value of the given key.\r\n\r\n`key` - The string key to retrieve the value for.\r\n\r\nReturns the configuration value, may be `null`.\r\n\r\n### Repository.setConfigValue(key, value)\r\n\r\nGet the config value of the given key.\r\n\r\n`key` - The string key to set in the config.\r\n\r\n`value` - The string value to set in the config for the given key.\r\n\r\nReturns `true` if setting the config value was successful, `false` otherwise.\r\n\r\n### Repository.getDiffStats(path)\r\n\r\nGet the number of lines added and removed comparing the working directory\r\ncontents of the given path to the HEAD version of the given path.\r\n\r\n`path` - The string repository-relative path to diff.\r\n\r\nReturns an object with `added` and `deleted` keys pointing to integer values\r\nthat always be >= 0.\r\n\r\n### Repository.getHeadBlob(path)\r\n\r\nGet the blob contents of the given path at HEAD. Similar to\r\n`git show HEAD:`.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns the string contents of the HEAD version of the path.\r\n\r\n### Repository.getHead()\r\n\r\nGet the reference or SHA-1 that HEAD points to such as `refs/heads/master`\r\nor a full SHA-1 if the repository is in a detached HEAD state.\r\n\r\nReturns the string reference name or SHA-1.\r\n\r\n### Repository.getIndexBlob(path)\r\n\r\nGet the blob contents of the given path in the index. Similar to\r\n`git show :`.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns the string contents of the index version of the path.\r\n\r\n### Repository.getLineDiffs(path, text, [options])\r\n\r\nGet the line diffs comparing the HEAD version of the given path and the given\r\ntext.\r\n\r\n`path` - The string repository-relative path.\r\n\r\n`text` - The string text to diff the HEAD contents of the path against.\r\n\r\n`options` - An optional object with the following keys:\r\n\r\n * `ignoreEolWhitespace` - `true` to ignore any whitespace diffs at the end of\r\n lines.\r\n * `useIndex` - `true` to compare against the index version instead of the HEAD\r\n version.\r\n\r\nReturns an array of objects that have `oldStart`, `oldLines`, `newStart`, and\r\n`newLines` keys pointing to integer values, may be `null` if the diff fails.\r\n\r\n### Repository.getMergeBase(commit1, commit2)\r\n\r\nGet the merge base of two commits.\r\n\r\n`commit1` - The string SHA-1 of the first commit.\r\n\r\n`commit2` - The string SHA-1 of the second commit.\r\n\r\nReturns the string SHA-1 of the merge base of `commit1` and `commit2` or `null`\r\nif there isn't one.\r\n\r\n### Repository.getPath()\r\n\r\nGet the path of the repository.\r\n\r\nReturns the string absolute path of the opened repository.\r\n\r\n### Repository.getReferences()\r\n\r\nGets all the local and remote references.\r\n\r\nReturns an object with three keys: `heads`, `remotes`, and `tags`.\r\nEach key can be an array of strings containing the reference names.\r\n\r\n### Repository.getReferenceTarget(ref)\r\n\r\nGet the target of the given reference.\r\n\r\n`ref` - The string reference.\r\n\r\nReturns the string target of the given reference.\r\n\r\n### Repository.getShortHead()\r\n\r\nGet a possibly shortened version of value returns by `getHead()`. This will\r\nremove leading segments of `refs/heads`, `refs/tags`, or `refs/remotes` and will\r\nalso shorten the SHA-1 of a detached HEAD to 7 characters.\r\n\r\nReturns a string shortened reference name or SHA-1.\r\n\r\n### Repository.getStatus([path])\r\n\r\nGet the status of a single path or all paths in the repository. This will not\r\ninclude ignored paths.\r\n\r\n`path` - An optional repository-relative path to limit the status reporting to.\r\n\r\nReturns an integer status number if a path is specified and returns an object\r\nwith path keys and integer status values if no path is specified.\r\n\r\n### Repository.getUpstreamBranch([branch])\r\n\r\nGet the upstream branch of the given branch.\r\n\r\n`branch` - The branch to find the upstream branch of (default: `HEAD`)\r\n\r\nReturns the string upstream branch reference name.\r\n\r\n### Repository.getWorkingDirectory()\r\n\r\nGet the working directory of the repository.\r\n\r\nReturns the string absolute path to the repository's working directory.\r\n\r\n### Repository.isIgnored(path)\r\n\r\nGet the ignored status of a given path.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns `true` if the path is ignored, `false` otherwise.\r\n\r\n### Repository.isPathModified(path)\r\n\r\nGet the modified status of a given path.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns `true` if the path is modified, `false` otherwise.\r\n\r\n### Repository.isPathNew(path)\r\n\r\nGet the new status of a given path.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns `true` if the path is new, `false` otherwise.\r\n\r\n### Repository.isPathDeleted(path)\r\n\r\nGet the deleted status of a given path.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns `true` if the path is deleted, `false` otherwise.\r\n\r\n### Repository.isStatusIgnored(status)\r\n\r\nCheck if a status value represents an ignored path.\r\n\r\n`status` - The integer status value.\r\n\r\nReturns `true` if the status is a ignored one, `false` otherwise.\r\n\r\n### Repository.isStatusModified(status)\r\n\r\nCheck if a status value represents a modified path.\r\n\r\n`status` - The integer status value.\r\n\r\nReturns `true` if the status is a modified one, `false` otherwise.\r\n\r\n### Repository.isStatusNew(status)\r\n\r\nCheck if a status value represents a new path.\r\n\r\n`status` - The integer status value.\r\n\r\nReturns `true` if the status is a new one, `false` otherwise.\r\n\r\n### Repository.isStatusDeleted(status)\r\n\r\nCheck if a status value represents a deleted path.\r\n\r\n`status` - The integer status value.\r\n\r\nReturns `true` if the status is a deleted one, `false` otherwise.\r\n\r\n### Repository.isSubmodule(path)\r\n\r\nCheck if the path is a submodule in the index.\r\n\r\n`path` - The string repository-relative path.\r\n\r\nReturns `true` if the path is a submodule, `false` otherwise.\r\n\r\n### Repository.refreshIndex()\r\n\r\nReread the index to update any values that have changed since the last time the\r\nindex was read.\r\n\r\n### Repository.relativize(path)\r\n\r\nRelativize the given path to the repository's working directory.\r\n\r\n`path` - The string path to relativize.\r\n\r\nReturns a repository-relative path if the given path is prefixed with the\r\nrepository's working directory path.\r\n\r\n### Repository.isWorkingDirectory(path)\r\n\r\nIs the given path the repository's working directory?\r\n\r\nIt is better to call this method than comparing a path directly against\r\nthe value of `getWorkingDirectory()` since this method handles slash\r\nnormalization on Windows, case insensitive filesystems, and symlinked\r\nrepositories.\r\n\r\n`path` - The string path to check.\r\n\r\nReturns `true` if the given path is the repository's working directory,\r\nfalse otherwise.\r\n\r\n### Repository.release()\r\n\r\nRelease the repository and close all file handles it has open. No other methods\r\ncan be called on the `Repository` object once it has been released.\r\n\r\n### Repository.submoduleForPath(path)\r\n\r\nGet the repository for the submodule that the path is located in.\r\n\r\n`path` - The absolute or repository-relative string path.\r\n\r\nReturns a `Repository` or `null` if the path isn't in a submodule.\r\n\r\n### Repository.add(path)\r\n\r\nStage the changes in `path` into the repository's index. Clear any conflict state\r\nassociated with `path`.\r\n\r\n`path` - A repository-relative string path.\r\n\r\nRaises an `Error` if the path isn't readable or if another exception occurs.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/spec/async-spec-helper-functions.js b/spec/async-spec-helper-functions.js deleted file mode 100644 index 850ba8e5..00000000 --- a/spec/async-spec-helper-functions.js +++ /dev/null @@ -1,52 +0,0 @@ -exports.beforeEach = function beforeEach (fn) { - global.beforeEach(function () { - const result = fn() - if (result instanceof Promise) { - waitsForPromise(result, this) - } - }) -} - -exports.afterEach = function afterEach (fn) { - global.afterEach(function () { - const result = fn() - if (result instanceof Promise) { - waitsForPromise(result, this) - } - }) -} - -;['it', 'fit', 'ffit', 'fffit'].forEach((name) => { - exports[name] = function (description, fn) { - if (fn === undefined) { - global[name](description) - return - } - - global[name](description, function () { - const result = fn() - if (result instanceof Promise) { - waitsForPromise(result, this) - } - }) - } -}) - -function waitsForPromise (promise, spec) { - let done = false - let error = null - - global.waitsFor('test promise to resolve', () => { - return done - }) - - promise.then( - () => { - done = true - }, - (e) => { - spec.fail(e) - done = true - } - ) -} diff --git a/spec/fixtures/ahead-behind.git/HEAD b/spec/fixtures/ahead-behind.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/spec/fixtures/ahead-behind.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/ahead-behind.git/config b/spec/fixtures/ahead-behind.git/config deleted file mode 100644 index fe5d0c28..00000000 --- a/spec/fixtures/ahead-behind.git/config +++ /dev/null @@ -1,12 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true -[branch "master"] - remote = origin - merge = refs/heads/master -[remote "origin"] - url = https://github.com/test/fixtures.git - fetch = +refs/heads/*:refs/remotes/origin/* diff --git a/spec/fixtures/ahead-behind.git/index b/spec/fixtures/ahead-behind.git/index deleted file mode 100644 index 9ebd6331..00000000 Binary files a/spec/fixtures/ahead-behind.git/index and /dev/null differ diff --git a/spec/fixtures/ahead-behind.git/objects/01/304958cafbf532dc719599cbf542855ec8c15f b/spec/fixtures/ahead-behind.git/objects/01/304958cafbf532dc719599cbf542855ec8c15f deleted file mode 100644 index 6fc9255a..00000000 Binary files a/spec/fixtures/ahead-behind.git/objects/01/304958cafbf532dc719599cbf542855ec8c15f and /dev/null differ diff --git a/spec/fixtures/ahead-behind.git/objects/08/fe2720d8e3fe3a5f81fbb289bc4c7a522f13da b/spec/fixtures/ahead-behind.git/objects/08/fe2720d8e3fe3a5f81fbb289bc4c7a522f13da deleted file mode 100644 index 5fa740fd..00000000 Binary files a/spec/fixtures/ahead-behind.git/objects/08/fe2720d8e3fe3a5f81fbb289bc4c7a522f13da and /dev/null differ diff --git a/spec/fixtures/ahead-behind.git/objects/2f/2309073d2f947005299cf23769d0fd7a4791d6 b/spec/fixtures/ahead-behind.git/objects/2f/2309073d2f947005299cf23769d0fd7a4791d6 deleted file mode 100644 index 3b724399..00000000 --- a/spec/fixtures/ahead-behind.git/objects/2f/2309073d2f947005299cf23769d0fd7a4791d6 +++ /dev/null @@ -1 +0,0 @@ -xÎA …aלb. Â”!1ƽKO0À´¥5õúÖx—ß¿xyi®µ4è¬Ý´EçÑ¢³Â)øh{dŽ^…Œ:'ê¨3ŒZÝy‘©A0ˆÑ ˜Å õÄ\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/spec/fixtures/no-commits.git/hooks/post-update.sample b/spec/fixtures/no-commits.git/hooks/post-update.sample deleted file mode 100755 index ec17ec19..00000000 --- a/spec/fixtures/no-commits.git/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/spec/fixtures/no-commits.git/hooks/pre-applypatch.sample b/spec/fixtures/no-commits.git/hooks/pre-applypatch.sample deleted file mode 100755 index 4142082b..00000000 --- a/spec/fixtures/no-commits.git/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/spec/fixtures/no-commits.git/hooks/pre-commit.sample b/spec/fixtures/no-commits.git/hooks/pre-commit.sample deleted file mode 100755 index 68d62d54..00000000 --- a/spec/fixtures/no-commits.git/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/spec/fixtures/no-commits.git/hooks/pre-push.sample b/spec/fixtures/no-commits.git/hooks/pre-push.sample deleted file mode 100755 index 6187dbf4..00000000 --- a/spec/fixtures/no-commits.git/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -z40=0000000000000000000000000000000000000000 - -while read local_ref local_sha remote_ref remote_sha -do - if [ "$local_sha" = $z40 ] - then - # Handle delete - : - else - if [ "$remote_sha" = $z40 ] - then - # New branch, examine all commits - range="$local_sha" - else - # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" - fi - - # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` - if [ -n "$commit" ] - then - echo >&2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/spec/fixtures/no-commits.git/hooks/pre-rebase.sample b/spec/fixtures/no-commits.git/hooks/pre-rebase.sample deleted file mode 100755 index 9773ed4c..00000000 --- a/spec/fixtures/no-commits.git/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up-to-date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -exit 0 - -################################################################ - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". diff --git a/spec/fixtures/no-commits.git/hooks/prepare-commit-msg.sample b/spec/fixtures/no-commits.git/hooks/prepare-commit-msg.sample deleted file mode 100755 index f093a02e..00000000 --- a/spec/fixtures/no-commits.git/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -case "$2,$3" in - merge,) - /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; - -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; - - *) ;; -esac - -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/spec/fixtures/no-commits.git/hooks/update.sample b/spec/fixtures/no-commits.git/hooks/update.sample deleted file mode 100755 index 80ba9413..00000000 --- a/spec/fixtures/no-commits.git/hooks/update.sample +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to block unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --bool hooks.allowunannotated) -allowdeletebranch=$(git config --bool hooks.allowdeletebranch) -denycreatebranch=$(git config --bool hooks.denycreatebranch) -allowdeletetag=$(git config --bool hooks.allowdeletetag) -allowmodifytag=$(git config --bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" -if [ "$newrev" = "$zero" ]; then - newrev_type=delete -else - newrev_type=$(git cat-file -t $newrev) -fi - -case "$refname","$newrev_type" in - refs/tags/*,commit) - # un-annotated tag - short_refname=${refname##refs/tags/} - if [ "$allowunannotated" != "true" ]; then - echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 diff --git a/spec/fixtures/no-commits.git/info/exclude b/spec/fixtures/no-commits.git/info/exclude deleted file mode 100644 index a5196d1b..00000000 --- a/spec/fixtures/no-commits.git/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff --git a/spec/fixtures/no-commits.git/objects/info/.gitkeep b/spec/fixtures/no-commits.git/objects/info/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/fixtures/no-commits.git/objects/pack/.gitkeep b/spec/fixtures/no-commits.git/objects/pack/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/fixtures/no-commits.git/refs/heads/.gitkeep b/spec/fixtures/no-commits.git/refs/heads/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/fixtures/no-commits.git/refs/tags/.gitkeep b/spec/fixtures/no-commits.git/refs/tags/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/fixtures/references.git/HEAD b/spec/fixtures/references.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/spec/fixtures/references.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/references.git/config b/spec/fixtures/references.git/config deleted file mode 100644 index b8e946b2..00000000 --- a/spec/fixtures/references.git/config +++ /dev/null @@ -1,10 +0,0 @@ -[user] - name = Hugh Bot - email = hubot@github.com -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true - precomposeunicode = false diff --git a/spec/fixtures/references.git/index b/spec/fixtures/references.git/index deleted file mode 100644 index 209c3b1d..00000000 Binary files a/spec/fixtures/references.git/index and /dev/null differ diff --git a/spec/fixtures/references.git/objects/01/304958cafbf532dc719599cbf542855ec8c15f b/spec/fixtures/references.git/objects/01/304958cafbf532dc719599cbf542855ec8c15f deleted file mode 100644 index 6fc9255a..00000000 Binary files a/spec/fixtures/references.git/objects/01/304958cafbf532dc719599cbf542855ec8c15f and /dev/null differ diff --git a/spec/fixtures/references.git/objects/08/fe2720d8e3fe3a5f81fbb289bc4c7a522f13da b/spec/fixtures/references.git/objects/08/fe2720d8e3fe3a5f81fbb289bc4c7a522f13da deleted file mode 100644 index 5fa740fd..00000000 Binary files a/spec/fixtures/references.git/objects/08/fe2720d8e3fe3a5f81fbb289bc4c7a522f13da and /dev/null differ diff --git a/spec/fixtures/references.git/objects/49/609769f01ce623c470503186474f30ecb6d398 b/spec/fixtures/references.git/objects/49/609769f01ce623c470503186474f30ecb6d398 deleted file mode 100644 index 36f11c6d..00000000 Binary files a/spec/fixtures/references.git/objects/49/609769f01ce623c470503186474f30ecb6d398 and /dev/null differ diff --git a/spec/fixtures/references.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e b/spec/fixtures/references.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e deleted file mode 100644 index d8989625..00000000 Binary files a/spec/fixtures/references.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e and /dev/null differ diff --git a/spec/fixtures/references.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 b/spec/fixtures/references.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 deleted file mode 100644 index ba1f06fc..00000000 Binary files a/spec/fixtures/references.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 and /dev/null differ diff --git a/spec/fixtures/references.git/objects/b2/c96bdffe1a8f239c2d450863e4a6caa6dcb655 b/spec/fixtures/references.git/objects/b2/c96bdffe1a8f239c2d450863e4a6caa6dcb655 deleted file mode 100644 index 1ae1255f..00000000 Binary files a/spec/fixtures/references.git/objects/b2/c96bdffe1a8f239c2d450863e4a6caa6dcb655 and /dev/null differ diff --git a/spec/fixtures/references.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/spec/fixtures/references.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 deleted file mode 100644 index 71122389..00000000 Binary files a/spec/fixtures/references.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 and /dev/null differ diff --git a/spec/fixtures/references.git/objects/f9/3e3a1a1525fb5b91020da86e44810c87a2d7bc b/spec/fixtures/references.git/objects/f9/3e3a1a1525fb5b91020da86e44810c87a2d7bc deleted file mode 100644 index 91fccd44..00000000 Binary files a/spec/fixtures/references.git/objects/f9/3e3a1a1525fb5b91020da86e44810c87a2d7bc and /dev/null differ diff --git a/spec/fixtures/references.git/refs/heads/diff-lines b/spec/fixtures/references.git/refs/heads/diff-lines deleted file mode 100644 index 8fc60f6c..00000000 --- a/spec/fixtures/references.git/refs/heads/diff-lines +++ /dev/null @@ -1 +0,0 @@ -49609769f01ce623c470503186474f30ecb6d398 diff --git a/spec/fixtures/references.git/refs/heads/getHeadOriginal b/spec/fixtures/references.git/refs/heads/getHeadOriginal deleted file mode 100644 index 8fc60f6c..00000000 --- a/spec/fixtures/references.git/refs/heads/getHeadOriginal +++ /dev/null @@ -1 +0,0 @@ -49609769f01ce623c470503186474f30ecb6d398 diff --git a/spec/fixtures/references.git/refs/heads/master b/spec/fixtures/references.git/refs/heads/master deleted file mode 100644 index 8fc60f6c..00000000 --- a/spec/fixtures/references.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -49609769f01ce623c470503186474f30ecb6d398 diff --git a/spec/fixtures/references.git/refs/remotes/origin/HEAD b/spec/fixtures/references.git/refs/remotes/origin/HEAD deleted file mode 100644 index 6efe28ff..00000000 --- a/spec/fixtures/references.git/refs/remotes/origin/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/remotes/origin/master diff --git a/spec/fixtures/references.git/refs/remotes/origin/getHeadOriginal b/spec/fixtures/references.git/refs/remotes/origin/getHeadOriginal deleted file mode 100644 index b8456606..00000000 --- a/spec/fixtures/references.git/refs/remotes/origin/getHeadOriginal +++ /dev/null @@ -1 +0,0 @@ -eb2996f7dfa693054ade3d77d0682abd74f39be0 diff --git a/spec/fixtures/references.git/refs/remotes/origin/master b/spec/fixtures/references.git/refs/remotes/origin/master deleted file mode 100644 index 183c11dc..00000000 --- a/spec/fixtures/references.git/refs/remotes/origin/master +++ /dev/null @@ -1 +0,0 @@ -0b8811ed58b6cea75d31be94634f42358b068962 diff --git a/spec/fixtures/references.git/refs/remotes/upstream/HEAD b/spec/fixtures/references.git/refs/remotes/upstream/HEAD deleted file mode 100644 index 6efe28ff..00000000 --- a/spec/fixtures/references.git/refs/remotes/upstream/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/remotes/origin/master diff --git a/spec/fixtures/references.git/refs/remotes/upstream/master b/spec/fixtures/references.git/refs/remotes/upstream/master deleted file mode 100644 index 183c11dc..00000000 --- a/spec/fixtures/references.git/refs/remotes/upstream/master +++ /dev/null @@ -1 +0,0 @@ -0b8811ed58b6cea75d31be94634f42358b068962 diff --git a/spec/fixtures/references.git/refs/tags/v1.0 b/spec/fixtures/references.git/refs/tags/v1.0 deleted file mode 100644 index b8456606..00000000 --- a/spec/fixtures/references.git/refs/tags/v1.0 +++ /dev/null @@ -1 +0,0 @@ -eb2996f7dfa693054ade3d77d0682abd74f39be0 diff --git a/spec/fixtures/references.git/refs/tags/v2.0 b/spec/fixtures/references.git/refs/tags/v2.0 deleted file mode 100644 index 183c11dc..00000000 --- a/spec/fixtures/references.git/refs/tags/v2.0 +++ /dev/null @@ -1 +0,0 @@ -0b8811ed58b6cea75d31be94634f42358b068962 diff --git a/spec/fixtures/subdir.git/COMMIT_EDITMSG b/spec/fixtures/subdir.git/COMMIT_EDITMSG deleted file mode 100644 index 9d4e7727..00000000 --- a/spec/fixtures/subdir.git/COMMIT_EDITMSG +++ /dev/null @@ -1,10 +0,0 @@ -first -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# On branch master -# -# Initial commit -# -# Changes to be committed: -# new file: dir/a.txt -# diff --git a/spec/fixtures/subdir.git/HEAD b/spec/fixtures/subdir.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/spec/fixtures/subdir.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/subdir.git/config b/spec/fixtures/subdir.git/config deleted file mode 100644 index 6c9406b7..00000000 --- a/spec/fixtures/subdir.git/config +++ /dev/null @@ -1,7 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true - precomposeunicode = true diff --git a/spec/fixtures/subdir.git/description b/spec/fixtures/subdir.git/description deleted file mode 100644 index 498b267a..00000000 --- a/spec/fixtures/subdir.git/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/spec/fixtures/subdir.git/hooks/applypatch-msg.sample b/spec/fixtures/subdir.git/hooks/applypatch-msg.sample deleted file mode 100755 index a5d7b84a..00000000 --- a/spec/fixtures/subdir.git/hooks/applypatch-msg.sample +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -commitmsg="$(git rev-parse --git-path hooks/commit-msg)" -test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} -: diff --git a/spec/fixtures/subdir.git/hooks/commit-msg.sample b/spec/fixtures/subdir.git/hooks/commit-msg.sample deleted file mode 100755 index b58d1184..00000000 --- a/spec/fixtures/subdir.git/hooks/commit-msg.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/spec/fixtures/subdir.git/hooks/post-update.sample b/spec/fixtures/subdir.git/hooks/post-update.sample deleted file mode 100755 index ec17ec19..00000000 --- a/spec/fixtures/subdir.git/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/spec/fixtures/subdir.git/hooks/pre-applypatch.sample b/spec/fixtures/subdir.git/hooks/pre-applypatch.sample deleted file mode 100755 index 4142082b..00000000 --- a/spec/fixtures/subdir.git/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/spec/fixtures/subdir.git/hooks/pre-commit.sample b/spec/fixtures/subdir.git/hooks/pre-commit.sample deleted file mode 100755 index 68d62d54..00000000 --- a/spec/fixtures/subdir.git/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/spec/fixtures/subdir.git/hooks/pre-push.sample b/spec/fixtures/subdir.git/hooks/pre-push.sample deleted file mode 100755 index 6187dbf4..00000000 --- a/spec/fixtures/subdir.git/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -z40=0000000000000000000000000000000000000000 - -while read local_ref local_sha remote_ref remote_sha -do - if [ "$local_sha" = $z40 ] - then - # Handle delete - : - else - if [ "$remote_sha" = $z40 ] - then - # New branch, examine all commits - range="$local_sha" - else - # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" - fi - - # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` - if [ -n "$commit" ] - then - echo >&2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/spec/fixtures/subdir.git/hooks/pre-rebase.sample b/spec/fixtures/subdir.git/hooks/pre-rebase.sample deleted file mode 100755 index 9773ed4c..00000000 --- a/spec/fixtures/subdir.git/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up-to-date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -exit 0 - -################################################################ - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". diff --git a/spec/fixtures/subdir.git/hooks/prepare-commit-msg.sample b/spec/fixtures/subdir.git/hooks/prepare-commit-msg.sample deleted file mode 100755 index f093a02e..00000000 --- a/spec/fixtures/subdir.git/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -case "$2,$3" in - merge,) - /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; - -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; - - *) ;; -esac - -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/spec/fixtures/subdir.git/hooks/update.sample b/spec/fixtures/subdir.git/hooks/update.sample deleted file mode 100755 index d8475837..00000000 --- a/spec/fixtures/subdir.git/hooks/update.sample +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to blocks unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --bool hooks.allowunannotated) -allowdeletebranch=$(git config --bool hooks.allowdeletebranch) -denycreatebranch=$(git config --bool hooks.denycreatebranch) -allowdeletetag=$(git config --bool hooks.allowdeletetag) -allowmodifytag=$(git config --bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" -if [ "$newrev" = "$zero" ]; then - newrev_type=delete -else - newrev_type=$(git cat-file -t $newrev) -fi - -case "$refname","$newrev_type" in - refs/tags/*,commit) - # un-annotated tag - short_refname=${refname##refs/tags/} - if [ "$allowunannotated" != "true" ]; then - echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 diff --git a/spec/fixtures/subdir.git/index b/spec/fixtures/subdir.git/index deleted file mode 100644 index 7307df29..00000000 Binary files a/spec/fixtures/subdir.git/index and /dev/null differ diff --git a/spec/fixtures/subdir.git/info/exclude b/spec/fixtures/subdir.git/info/exclude deleted file mode 100644 index a5196d1b..00000000 --- a/spec/fixtures/subdir.git/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff --git a/spec/fixtures/subdir.git/logs/HEAD b/spec/fixtures/subdir.git/logs/HEAD deleted file mode 100644 index 014e0c37..00000000 --- a/spec/fixtures/subdir.git/logs/HEAD +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 0161b71e6fec1c93588328e95a1b35d29dc11535 joshaber 1455122054 -0500 commit (initial): first diff --git a/spec/fixtures/subdir.git/logs/refs/heads/master b/spec/fixtures/subdir.git/logs/refs/heads/master deleted file mode 100644 index 014e0c37..00000000 --- a/spec/fixtures/subdir.git/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 0161b71e6fec1c93588328e95a1b35d29dc11535 joshaber 1455122054 -0500 commit (initial): first diff --git a/spec/fixtures/subdir.git/objects/01/61b71e6fec1c93588328e95a1b35d29dc11535 b/spec/fixtures/subdir.git/objects/01/61b71e6fec1c93588328e95a1b35d29dc11535 deleted file mode 100644 index e9b46fa6..00000000 --- a/spec/fixtures/subdir.git/objects/01/61b71e6fec1c93588328e95a1b35d29dc11535 +++ /dev/null @@ -1,2 +0,0 @@ -xA -à E»ös'™I"„Ы¨i,Á˜û×MöÝ=>ïóbÉ95À‰n­Š€1ð¸¸@.ª(‹ „UëãKUi6þl{©ð)ÇîƒTX/z¾³OßG,y$fËwËÖš¾ö\ëþ¥ÿy4šêÑÌí<6 \ No newline at end of file diff --git a/spec/fixtures/subdir.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 b/spec/fixtures/subdir.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 deleted file mode 100644 index ba1f06fc..00000000 Binary files a/spec/fixtures/subdir.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 and /dev/null differ diff --git a/spec/fixtures/subdir.git/objects/93/1b5389b49cf064be5ee1eb81ff95f7ccdfff47 b/spec/fixtures/subdir.git/objects/93/1b5389b49cf064be5ee1eb81ff95f7ccdfff47 deleted file mode 100644 index 3506513e..00000000 Binary files a/spec/fixtures/subdir.git/objects/93/1b5389b49cf064be5ee1eb81ff95f7ccdfff47 and /dev/null differ diff --git a/spec/fixtures/subdir.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/spec/fixtures/subdir.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 deleted file mode 100644 index 71122389..00000000 Binary files a/spec/fixtures/subdir.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 and /dev/null differ diff --git a/spec/fixtures/subdir.git/refs/heads/master b/spec/fixtures/subdir.git/refs/heads/master deleted file mode 100644 index 4e9b28da..00000000 --- a/spec/fixtures/subdir.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0161b71e6fec1c93588328e95a1b35d29dc11535 diff --git a/spec/fixtures/submodule.git/HEAD b/spec/fixtures/submodule.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/spec/fixtures/submodule.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/submodule.git/index b/spec/fixtures/submodule.git/index deleted file mode 100644 index f7401455..00000000 Binary files a/spec/fixtures/submodule.git/index and /dev/null differ diff --git a/spec/fixtures/submodule.git/objects/1b/cb7091215e8cf32c6a666e7a86c30dd863106c b/spec/fixtures/submodule.git/objects/1b/cb7091215e8cf32c6a666e7a86c30dd863106c deleted file mode 100644 index 319dde82..00000000 --- a/spec/fixtures/submodule.git/objects/1b/cb7091215e8cf32c6a666e7a86c30dd863106c +++ /dev/null @@ -1,2 +0,0 @@ -xŽKn1 @»Î)|¢8ÿ‘Pë.{Û14‚ÌTC¦½~AÜ€å{‹§'Kïm€ ø6VUðÒD>z¤ZJ.…×SĘR²½"ùBœÌ­:ˆ6ãDìÓT…Y܉=g²˜²DG"\­r°jhßË -ŸúÛfø¢¿&—ûËoO:œ;µëN–þè“Ë9 x·ÅZs·÷Ï¡¯̱Ö6Ÿá¶q_êvUóÆóMî \ No newline at end of file diff --git a/spec/fixtures/submodule.git/objects/3c/469a3531ad88788b2bdf5156660213e1a38ab6 b/spec/fixtures/submodule.git/objects/3c/469a3531ad88788b2bdf5156660213e1a38ab6 deleted file mode 100644 index 0d223fe3..00000000 Binary files a/spec/fixtures/submodule.git/objects/3c/469a3531ad88788b2bdf5156660213e1a38ab6 and /dev/null differ diff --git a/spec/fixtures/submodule.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e b/spec/fixtures/submodule.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e deleted file mode 100644 index d8989625..00000000 Binary files a/spec/fixtures/submodule.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e and /dev/null differ diff --git a/spec/fixtures/submodule.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 b/spec/fixtures/submodule.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 deleted file mode 100644 index ba1f06fc..00000000 Binary files a/spec/fixtures/submodule.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 and /dev/null differ diff --git a/spec/fixtures/submodule.git/objects/6c/3696b41ca787956d25e60da56a05763a22e6a3 b/spec/fixtures/submodule.git/objects/6c/3696b41ca787956d25e60da56a05763a22e6a3 deleted file mode 100644 index 74cebe4c..00000000 Binary files a/spec/fixtures/submodule.git/objects/6c/3696b41ca787956d25e60da56a05763a22e6a3 and /dev/null differ diff --git a/spec/fixtures/submodule.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/spec/fixtures/submodule.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 deleted file mode 100644 index 71122389..00000000 Binary files a/spec/fixtures/submodule.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 and /dev/null differ diff --git a/spec/fixtures/submodule.git/refs/heads/master b/spec/fixtures/submodule.git/refs/heads/master deleted file mode 100644 index 6a18020b..00000000 --- a/spec/fixtures/submodule.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -1bcb7091215e8cf32c6a666e7a86c30dd863106c diff --git a/spec/fixtures/upstream.git/HEAD b/spec/fixtures/upstream.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/spec/fixtures/upstream.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/upstream.git/config b/spec/fixtures/upstream.git/config deleted file mode 100644 index 8e557119..00000000 --- a/spec/fixtures/upstream.git/config +++ /dev/null @@ -1,9 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true -[branch "master"] - remote = origin - merge = refs/heads/master diff --git a/spec/fixtures/upstream.git/index b/spec/fixtures/upstream.git/index deleted file mode 100644 index 740bb394..00000000 Binary files a/spec/fixtures/upstream.git/index and /dev/null differ diff --git a/spec/fixtures/upstream.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e b/spec/fixtures/upstream.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e deleted file mode 100644 index d8989625..00000000 Binary files a/spec/fixtures/upstream.git/objects/50/719ab369dcbbc2fb3b7a0167c52accbd0eb40e and /dev/null differ diff --git a/spec/fixtures/upstream.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 b/spec/fixtures/upstream.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 deleted file mode 100644 index ba1f06fc..00000000 Binary files a/spec/fixtures/upstream.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 and /dev/null differ diff --git a/spec/fixtures/upstream.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/spec/fixtures/upstream.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 deleted file mode 100644 index 71122389..00000000 Binary files a/spec/fixtures/upstream.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 and /dev/null differ diff --git a/spec/fixtures/upstream.git/refs/heads/master b/spec/fixtures/upstream.git/refs/heads/master deleted file mode 100644 index 5ba60286..00000000 --- a/spec/fixtures/upstream.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -50719ab369dcbbc2fb3b7a0167c52accbd0eb40e diff --git a/spec/fixtures/upstream.git/refs/remotes/origin/master b/spec/fixtures/upstream.git/refs/remotes/origin/master deleted file mode 100644 index 5ba60286..00000000 --- a/spec/fixtures/upstream.git/refs/remotes/origin/master +++ /dev/null @@ -1 +0,0 @@ -50719ab369dcbbc2fb3b7a0167c52accbd0eb40e diff --git a/spec/fixtures/whitespace.git/HEAD b/spec/fixtures/whitespace.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/spec/fixtures/whitespace.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/whitespace.git/config b/spec/fixtures/whitespace.git/config deleted file mode 100644 index 6c9406b7..00000000 --- a/spec/fixtures/whitespace.git/config +++ /dev/null @@ -1,7 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true - precomposeunicode = true diff --git a/spec/fixtures/whitespace.git/index b/spec/fixtures/whitespace.git/index deleted file mode 100644 index 86dc7309..00000000 Binary files a/spec/fixtures/whitespace.git/index and /dev/null differ diff --git a/spec/fixtures/whitespace.git/objects/5f/6a1c992cfafadd97053fae380aef21a964621a b/spec/fixtures/whitespace.git/objects/5f/6a1c992cfafadd97053fae380aef21a964621a deleted file mode 100644 index 73620c13..00000000 Binary files a/spec/fixtures/whitespace.git/objects/5f/6a1c992cfafadd97053fae380aef21a964621a and /dev/null differ diff --git a/spec/fixtures/whitespace.git/objects/9e/9f22baaf485ce95df8de089024e5fa13bc7fb4 b/spec/fixtures/whitespace.git/objects/9e/9f22baaf485ce95df8de089024e5fa13bc7fb4 deleted file mode 100644 index 563d51fc..00000000 Binary files a/spec/fixtures/whitespace.git/objects/9e/9f22baaf485ce95df8de089024e5fa13bc7fb4 and /dev/null differ diff --git a/spec/fixtures/whitespace.git/objects/e2/81c6b8b1c5b44193540a0dc1ada9957d07677c b/spec/fixtures/whitespace.git/objects/e2/81c6b8b1c5b44193540a0dc1ada9957d07677c deleted file mode 100644 index 078a7661..00000000 Binary files a/spec/fixtures/whitespace.git/objects/e2/81c6b8b1c5b44193540a0dc1ada9957d07677c and /dev/null differ diff --git a/spec/fixtures/whitespace.git/refs/heads/master b/spec/fixtures/whitespace.git/refs/heads/master deleted file mode 100644 index 8bf7db85..00000000 --- a/spec/fixtures/whitespace.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -5f6a1c992cfafadd97053fae380aef21a964621a diff --git a/spec/git-spec.js b/spec/git-spec.js deleted file mode 100644 index ac51d274..00000000 --- a/spec/git-spec.js +++ /dev/null @@ -1,1149 +0,0 @@ -const git = require('../src/git') -const path = require('path') -const fs = require('fs-plus') -const {exec} = require('child_process') -const wrench = require('wrench') -const temp = require('temp') -const _ = require('underscore') -const {it, fit, beforeEach} = require('./async-spec-helper-functions') - -describe('git', () => { - let repo - - afterEach(() => { - if (repo) repo.release() - }) - - describe('.open(path)', () => { - describe('when the path is a repository', () => { - it('returns a repository', () => { - expect(git.open(__dirname)).not.toBeNull() - }) - }) - - describe("when the path isn't a repository", () => { - it('returns null', () => { - expect(git.open('/tmp/path/does/not/exist')).toBeNull() - }) - }) - - describe('when limiting upwards traversal', () => { - it('returns null', () => { - const repositorySubdirectoryPath = path.join(path.dirname(__dirname), 'spec', 'fixtures') - expect(git.open(repositorySubdirectoryPath, false)).toBeNull() - }) - }) - }) - - describe('.getPath()', () => { - it('returns the path to the .git directory', () => { - const repositoryPath = git.open(__dirname).getPath() - let currentGitPath = path.join(path.dirname(__dirname), '.git/') - if (process.platform === 'win32') { currentGitPath = currentGitPath.replace(/\\/g, '/') } - expect(repositoryPath).toBe(currentGitPath) - }) - }) - - describe('.getWorkingDirectory()', () => { - it('returns the path to the working directory', () => { - const workingDirectory = git.open(__dirname).getWorkingDirectory() - let cwd = path.dirname(__dirname) - if (process.platform === 'win32') { cwd = cwd.replace(/\\/g, '/') } - expect(workingDirectory).toBe(cwd) - }) - }) - - describe('.getHead()', () => { - describe('when a branch is checked out', () => { - it("returns the branch's full path", () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - expect(repo.getHead()).toBe('refs/heads/master') - }) - - it("resolves with the branch's full path", async () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - expect(await repo.getHeadAsync()).toBe('refs/heads/master') - }) - }) - - describe('when the HEAD is detached', () => { - it('return the SHA-1 that is checked out', () => { - repo = git.open(path.join(__dirname, 'fixtures/detached.git')) - expect(repo.getHead()).toBe('50719ab369dcbbc2fb3b7a0167c52accbd0eb40e') - }) - - it('resolves with the SHA-1 that is checked out', async () => { - repo = git.open(path.join(__dirname, 'fixtures/detached.git')) - expect(await repo.getHeadAsync()).toBe('50719ab369dcbbc2fb3b7a0167c52accbd0eb40e') - }) - }) - - describe('when repo has no commits', () => { - it('returns null', () => { - repo = git.open(path.join(__dirname, 'fixtures/no-commits.git')) - expect(repo.getHead()).toBe(null) - }) - - it('resolves with null', async () => { - repo = git.open(path.join(__dirname, 'fixtures/no-commits.git')) - expect(await repo.getHeadAsync()).toBe(null) - }) - }) - }) - - describe('.getShortHead()', () => { - describe('when a branch is checked out', () => { - it("returns the branch's name", () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - expect(repo.getShortHead()).toBe('master') - }) - }) - - describe('when the HEAD is detached', () => { - it('return the abbreviated SHA-1 that is checked out', () => { - repo = git.open(path.join(__dirname, 'fixtures/detached.git')) - expect(repo.getShortHead()).toBe('50719ab') - }) - }) - }) - - describe('.isIgnored(path)', () => { - let ignoreRepoRoot, ignoreRepoDir - - beforeEach(() => { - // this setup should be done in beforeAll, but jasmine 1.x doesn't have it. - ignoreRepoRoot = temp.mkdirSync('ignore-dir') - ignoreRepoDir = path.join(ignoreRepoRoot, 'ignored') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/ignored-workspace/'), ignoreRepoDir) - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/ignored.git'), path.join(ignoreRepoDir, '.git')) - }) - - afterEach(() => wrench.rmdirSyncRecursive(ignoreRepoRoot)) - - describe('when the path is undefined', () => { - it('return false', () => { - repo = git.open(ignoreRepoDir) - expect(repo.isIgnored()).toBe(false) - }) - }) - - describe('when the path is ignored', () => { - it('returns true', () => { - repo = git.open(ignoreRepoDir) - expect(repo.isIgnored('a.txt')).toBe(true) - expect(repo.isIgnored('subdir/subdir')).toBe(true) - expect(repo.isIgnored('a.foo')).toBe(true) - expect(repo.isIgnored('subdir/a.foo')).toBe(true) - }) - }) - - describe('when the path is not ignored', () => { - it('return false', () => { - repo = git.open(ignoreRepoDir) - expect(repo.isIgnored('b.txt')).toBe(false) - expect(repo.isIgnored('subdir')).toBe(false) - expect(repo.isIgnored('subdir/yak.txt')).toBe(false) - }) - }) - }) - - describe('.isSubmodule(path)', () => { - describe('when the path is undefined', () => { - it('return false', () => { - repo = git.open(path.join(__dirname, 'fixtures/submodule.git')) - expect(repo.isSubmodule()).toBe(false) - }) - }) - - describe('when the path is a submodule', () => { - it('returns true', () => { - repo = git.open(path.join(__dirname, 'fixtures/submodule.git')) - expect(repo.isSubmodule('a')).toBe(true) - }) - }) - - describe('when the path is not a submodule', () => { - it('return false', () => { - repo = git.open(path.join(__dirname, 'fixtures/submodule.git')) - expect(repo.isSubmodule('b')).toBe(false) - }) - }) - }) - - describe('.getConfigValue(key)', () => { - it('returns the value for the key', () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - expect(repo.getConfigValue('core.repositoryformatversion')).toBe('0') - expect(repo.getConfigValue('core.ignorecase')).toBe('true') - expect(repo.getConfigValue('not.section')).toBe(null) - }) - }) - - describe('.setConfigValue(key, value)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - it('sets the key to the value in the config', () => { - expect(repo.setConfigValue()).toBe(false) - expect(repo.setConfigValue('1')).toBe(false) - expect(repo.setConfigValue('a.b', 'test')).toBe(true) - expect(repo.getConfigValue('a.b')).toBe('test') - expect(repo.setConfigValue('a.b.c', 'foo')).toBe(true) - expect(repo.getConfigValue('a.b.c')).toBe('foo') - }) - }) - - describe('.isPathModified(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when a path is deleted', () => { - it('returns true', () => expect(repo.isPathModified('a.txt')).toBe(true)) - }) - - describe('when a path is modified', () => { - it('returns true', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'a.txt'), 'changing a.txt', 'utf8') - expect(repo.isPathModified('a.txt')).toBe(true) - }) - }) - - describe('when a path is new', () => { - it('returns false', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'new.txt'), 'new', 'utf8') - expect(repo.isPathModified('new.txt')).toBe(false) - }) - }) - }) - - describe('.isPathDeleted(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when a path is deleted', () => { - it('returns true', () => expect(repo.isPathDeleted('a.txt')).toBe(true)) - }) - - describe('when a path is modified', () => { - it('returns false', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'a.txt'), 'changing a.txt', 'utf8') - expect(repo.isPathDeleted('a.txt')).toBe(false) - }) - }) - - describe('when a path is new', () => { - it('returns false', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'new.txt'), 'new', 'utf8') - expect(repo.isPathDeleted('new.txt')).toBe(false) - }) - }) - }) - - describe('.isPathNew(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when a path is deleted', () => { - it('returns false', () => expect(repo.isPathNew('a.txt')).toBe(false)) - }) - - describe('when a path is modified', () => { - it('returns false', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'a.txt'), 'changing a.txt', 'utf8') - expect(repo.isPathNew('a.txt')).toBe(false) - }) - }) - - describe('when a path is new', () => { - it('returns true', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'new.txt'), 'new', 'utf8') - expect(repo.isPathNew('new.txt')).toBe(true) - }) - }) - }) - - describe('isPathStaged(path)', () => { - let repoDirectory - - beforeEach(() => { - repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when a path is new and staged', () => { - it('returns true ', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'new.txt'), 'new', 'utf8') - expect(repo.isPathStaged('new.txt')).toBe(false) - repo.add('new.txt') - expect(repo.isPathStaged('new.txt')).toBe(true) - }) - }) - - describe('when a path is modified and staged', () => { - it('returns true ', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'a.txt'), 'changing a.txt', 'utf8') - expect(repo.isPathStaged('a.txt')).toBe(false) - repo.add('a.txt') - expect(repo.isPathStaged('a.txt')).toBe(true) - }) - }) - - describe('when a path is deleted and staged', () => { - it('returns true ', () => { - expect(repo.isPathStaged('a.txt')).toBe(false) - const gitCommandHandler = jasmine.createSpy('gitCommandHandler') - execCommands([`cd ${repoDirectory}`, 'git rm -f a.txt'], gitCommandHandler) - - waitsFor(() => gitCommandHandler.callCount === 1) - - runs(() => expect(repo.isPathStaged('a.txt')).toBe(true)) - }) - }) - }) - - describe('.isStatusIgnored(status)', () => { - it('returns true when the status is ignored, false otherwise', () => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/ignored.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - const ignoreFile = path.join(repo.getWorkingDirectory(), '.git/info/exclude') - fs.writeFileSync(ignoreFile, 'c.txt') - fs.writeFileSync(path.join(repoDirectory, 'c.txt'), '') - - expect(repo.isStatusIgnored(repo.getStatus('c.txt'))).toBe(true) - expect(repo.isStatusIgnored(repo.getStatus('b.txt'))).toBe(false) - expect(repo.isStatusIgnored()).toBe(false) - }) - }) - - describe('.getUpstreamBranch()', () => { - describe('when no upstream branch exists', () => { - it('returns null', () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - expect(repo.getUpstreamBranch()).toBe(null) - }) - }) - - describe('when an upstream branch exists', () => { - it('returns the full path to the branch', () => { - repo = git.open(path.join(__dirname, 'fixtures/upstream.git')) - expect(repo.getUpstreamBranch()).toBe('refs/remotes/origin/master') - }) - }) - }) - - describe('.checkoutReference(reference, [create])', () => { - let repoDirectory = null - - beforeEach(() => { - repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/references.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - expect(repo.getHead()).toBe('refs/heads/master') - }) - - describe('when a local reference exists', () => { - it('checks a branch out if passed a short reference', () => { - expect(repo.checkoutReference('getHeadOriginal')).toBe(true) - expect(repo.getHead()).toBe('refs/heads/getHeadOriginal') - }) - - it('checks a branch out if passed a long reference', () => { - expect(repo.checkoutReference('refs/heads/getHeadOriginal')).toBe(true) - expect(repo.getHead()).toBe('refs/heads/getHeadOriginal') - }) - - // in this test, we need to fake a commit and try to switch to a new branch - it('does not check a branch out if the dirty tree interferes', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'README.md'), 'great words', 'utf8') - const gitCommandHandler = jasmine.createSpy('gitCommandHandler') - execCommands([`cd ${repoDirectory}`, 'git add .', "git commit -m 'comitting'"], gitCommandHandler) - - waitsFor(() => gitCommandHandler.callCount === 1) - - runs(() => { - expect(repo.checkoutReference('refs/heads/getHeadOriginal')).toBe(true) - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'README.md'), 'more words', 'utf8') - expect(repo.checkoutReference('refs/heads/master')).toBe(false) - expect(repo.getHead()).toBe('refs/heads/getHeadOriginal') - }) - }) - - it('does check a branch out if the dirty tree does not interfere', () => { - fs.writeFileSync(path.join(repo.getWorkingDirectory(), 'new_file.md'), 'a new file', 'utf8') - expect(repo.checkoutReference('refs/heads/getHeadOriginal')).toBe(true) - }) - }) - - describe('when a local reference doesn\'t exist', () => { - it('does nothing if branch creation was not specified', () => expect(repo.checkoutReference('refs/heads/whoop-whoop')).toBe(false)) - - it('creates the new branch (if asked to)', () => { - expect(repo.checkoutReference('refs/heads/whoop-whoop', true)).toBe(true) - expect(repo.getHead()).toBe('refs/heads/whoop-whoop') - }) - - it('does nothing if the new branch is malformed (even if asked to)', () => { - expect(repo.checkoutReference('refs/heads/inv@{id', true)).toBe(false) - expect(repo.getHead()).toBe('refs/heads/master') - }) - - describe('when a short reference is passed', () => { - it('does nothing if branch creation was not specified', () => expect(repo.checkoutReference('bananas')).toBe(false)) - - it('creates the new branch (if asked to)', () => { - expect(repo.checkoutReference('bananas', true)).toBe(true) - expect(repo.getHead()).toBe('refs/heads/bananas') - }) - }) - }) - }) - - describe('.checkoutHead(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when the path exists', () => { - it('replaces the file contents with the HEAD revision and returns true', () => { - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'changing a.txt', 'utf8') - expect(repo.checkoutHead('a.txt')).toBe(true) - const lineEnding = process.platform === 'win32' ? '\r\n' : '\n' - expect(fs.readFileSync(filePath, 'utf8')).toBe(`first line${lineEnding}`) - }) - }) - - describe('when the path is undefined', () => { - it('returns false', () => expect(repo.checkoutHead()).toBe(false)) - }) - }) - - describe('.getReferences()', () => { - it('returns a list of all the references', () => { - const referencesObj = { - heads: [ 'refs/heads/diff-lines', 'refs/heads/getHeadOriginal', 'refs/heads/master' ], - remotes: [ 'refs/remotes/origin/getHeadOriginal', 'refs/remotes/origin/HEAD', 'refs/remotes/origin/master', 'refs/remotes/upstream/HEAD', 'refs/remotes/upstream/master' ], - tags: [ 'refs/tags/v1.0', 'refs/tags/v2.0' ] - } - - repo = git.open(path.join(__dirname, 'fixtures/references.git')) - expect(repo.getReferences()).toEqual(referencesObj) - }) - }) - - describe('.getReferenceTarget(branch)', () => { - it('returns the SHA-1 for a reference', () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - expect(repo.getReferenceTarget('HEAD2')).toBe(null) - expect(repo.getReferenceTarget('HEAD')).toBe('b2c96bdffe1a8f239c2d450863e4a6caa6dcb655') - expect(repo.getReferenceTarget('refs/heads/master')).toBe('b2c96bdffe1a8f239c2d450863e4a6caa6dcb655') - }) - }) - - describe('.getDiffStats(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when the path is deleted', () => { - it('returns of number of lines deleted', () => { - expect(repo.getDiffStats('a.txt')).toEqual({added: 0, deleted: 1}) - }) - }) - - describe('when the path is modified', () => { - it('returns the number of lines added and deleted', () => { - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'changing\na.txt', 'utf8') - expect(repo.getDiffStats('a.txt')).toEqual({added: 2, deleted: 1}) - }) - }) - - describe('when the path is new', () => { - it('returns that no lines were added or deleted', () => { - const filePath = path.join(repo.getWorkingDirectory(), 'b.txt') - fs.writeFileSync(filePath, 'changing\nb.txt\nwith lines', 'utf8') - expect(repo.getDiffStats('b.txt')).toEqual({added: 0, deleted: 0}) - }) - }) - - describe('when the repository has no HEAD', () => { - it('returns that no lines were added and deleted', () => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - fs.unlinkSync(path.join(repoDirectory, '.git/HEAD')) - expect(repo.getDiffStats('b.txt')).toEqual({added: 0, deleted: 0}) - }) - }) - }) - - describe('.getHeadBlob(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when the path is modified', () => { - it('returns the HEAD blob contents', () => { - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'changing\na.txt', 'utf8') - expect(repo.getHeadBlob('a.txt')).toBe('first line\n') - }) - }) - - describe('when the path is not modified', () => { - it('returns the HEAD blob contents', () => expect(repo.getHeadBlob('a.txt')).toBe('first line\n')) - }) - - describe('when the path does not exist', () => { - it('returns null', () => expect(repo.getHeadBlob('i-do-not-exist.txt')).toBeNull()) - }) - }) - - describe('.getIndexBlob(path)', () => { - let repoDirectory - - beforeEach(() => { - repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - describe('when the path is staged', () => { - it('returns the index blob contents', () => { - expect(repo.getIndexBlob('a.txt')).toBe('first line\n') - - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'changing\na.txt', 'utf8') - expect(repo.getIndexBlob('a.txt')).toBe('first line\n') - - const gitCommandHandler = jasmine.createSpy('gitCommandHandler') - execCommands([`cd ${repoDirectory}`, 'git add a.txt'], gitCommandHandler) - - waitsFor(() => gitCommandHandler.callCount === 1) - - runs(() => expect(repo.getIndexBlob('a.txt')).toBe('changing\na.txt')) - }) - }) - - describe('when the path is not staged', () => { - it('returns the index blob contents', () => { - expect(repo.getIndexBlob('a.txt')).toBe('first line\n') - - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'changing\na.txt', 'utf8') - expect(repo.getIndexBlob('a.txt')).toBe('first line\n') - }) - }) - - describe('when the path does not exist', () => { - it('returns null', () => expect(repo.getIndexBlob('i-do-not-exist.txt')).toBeNull()) - }) - }) - - describe('.getStatus([path])', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - - const newFilePath = path.join(repo.getWorkingDirectory(), 'b.txt') - fs.writeFileSync(newFilePath, '', 'utf8') - - const ignoreFile = path.join(repo.getWorkingDirectory(), '.git/info/exclude') - fs.writeFileSync(ignoreFile, 'c.txt', 'utf8') - const ignoredFilePath = path.join(repo.getWorkingDirectory(), 'c.txt') - fs.writeFileSync(ignoredFilePath, '', 'utf8') - }) - - describe('when no path is specified', () => { - it('returns the status of all modified paths', () => { - const statuses = repo.getStatus() - expect(statuses).toEqual({ - 'a.txt': 1 << 9, - 'b.txt': 1 << 7 - }) - }) - - it('resolves with the status of all modified paths', async () => { - const statuses = await repo.getStatusAsync() - expect(statuses).toEqual({ - 'a.txt': 1 << 9, - 'b.txt': 1 << 7 - }) - }) - }) - - describe('when a path is specified', () => { - it('returns the status of the given path', () => { - expect(repo.getStatus('a.txt')).toBe(1 << 9) - }) - }) - }) - - describe('.getStatusForPaths([paths])', () => { - let repoDirectory, filePath - - beforeEach(() => { - repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/subdir.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - - const dir = path.join(repo.getWorkingDirectory(), 'dir') - filePath = path.join(dir, 'a.txt') - fs.writeFileSync(filePath, 'hey there', 'utf8') - }) - - describe('when a path is specified', () => { - it('returns the status of only that path', () => { - const statuses = repo.getStatusForPaths(['dir/**']) - expect(_.keys(statuses).length).toBe(1) - - const status = statuses['dir/a.txt'] - expect(repo.isStatusModified(status)).toBe(true) - expect(repo.isStatusNew(status)).toBe(false) - }) - - it('resolves with the status of only that path', async () => { - const statuses = await repo.getStatusForPathsAsync(['dir/**']) - expect(_.keys(statuses).length).toBe(1) - - const status = statuses['dir/a.txt'] - expect(repo.isStatusModified(status)).toBe(true) - expect(repo.isStatusNew(status)).toBe(false) - }) - - it('returns the status of only that path2', () => { - fs.writeFileSync(filePath, '', 'utf8') - - const statuses = repo.getStatusForPaths(['dir/**']) - expect(_.keys(statuses).length).toBe(0) - }) - }) - - describe('when no path is specified', () => { - it('returns an empty object', () => { - const statuses = repo.getStatusForPaths() - expect(_.keys(statuses).length).toBe(0) - }) - }) - - describe('when an empty array is specified', () => { - it('returns an empty object', () => { - const statuses = repo.getStatusForPaths([]) - expect(_.keys(statuses).length).toBe(0) - }) - }) - - describe('when an empty string is specified', () => { - it('returns an empty object', () => { - const statuses = repo.getStatusForPaths(['']) - expect(_.keys(statuses).length).toBe(1) - }) - }) - }) - - describe('.getAheadBehindCount()', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/ahead-behind.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - }) - - it('returns the number of commits ahead of and behind the upstream branch', () => { - let counts = repo.getAheadBehindCount() - expect(counts).toEqual({ahead: 3, behind: 2}) - - counts = repo.getAheadBehindCount('refs/heads/master') - expect(counts).toEqual({ahead: 3, behind: 2}) - - counts = repo.getAheadBehindCount('master') - expect(counts).toEqual({ahead: 3, behind: 2}) - - counts = repo.getAheadBehindCount('refs/heads/masterblaster') - expect(counts).toEqual({ahead: 0, behind: 0}) - - counts = repo.getAheadBehindCount('') - expect(counts).toEqual({ahead: 0, behind: 0}) - }) - - it('resolves with the number of commits ahead of and behind the upstream branch', async () => { - let counts = await repo.getAheadBehindCountAsync() - expect(counts).toEqual({ahead: 3, behind: 2}) - - counts = await repo.getAheadBehindCountAsync('refs/heads/master') - expect(counts).toEqual({ahead: 3, behind: 2}) - - counts = await repo.getAheadBehindCountAsync('master') - expect(counts).toEqual({ahead: 3, behind: 2}) - - counts = await repo.getAheadBehindCountAsync('refs/heads/masterblaster') - expect(counts).toEqual({ahead: 0, behind: 0}) - - counts = await repo.getAheadBehindCountAsync('') - expect(counts).toEqual({ahead: 0, behind: 0}) - }) - }) - - describe('.getLineDiffs(path, text, options)', () => { - it('returns all hunks that differ', () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - - let diffs = repo.getLineDiffs('a.txt', 'first line is different') - expect(diffs.length).toBe(1) - expect(diffs[0].oldStart).toBe(1) - expect(diffs[0].oldLines).toBe(1) - expect(diffs[0].newStart).toBe(1) - expect(diffs[0].newLines).toBe(1) - - diffs = repo.getLineDiffs('a.txt', 'first line\nsecond line') - expect(diffs.length).toBe(1) - expect(diffs[0].oldStart).toBe(1) - expect(diffs[0].oldLines).toBe(0) - expect(diffs[0].newStart).toBe(2) - expect(diffs[0].newLines).toBe(1) - - diffs = repo.getLineDiffs('a.txt', '') - expect(diffs.length).toBe(1) - expect(diffs[0].oldStart).toBe(1) - expect(diffs[0].oldLines).toBe(1) - expect(diffs[0].newStart).toBe(0) - expect(diffs[0].newLines).toBe(0) - }) - - it("returns null for paths that don't exist", () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - - const diffs = repo.getLineDiffs('i-dont-exists.txt', 'content') - expect(diffs).toBeNull() - }) - - describe('ignoreSpaceAtEOL option', () => { - it('ignores eol of line whitespace changes', () => { - repo = git.open(path.join(__dirname, 'fixtures/whitespace.git')) - - let diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreEolWhitespace: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreEolWhitespace: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceAtEOL: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceAtEOL: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: true}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: true}) - expect(diffs.length).toBe(1) - }) - }) - - describe('ignoreSpaceChange option', () => { - it('ignores whitespace changes', () => { - repo = git.open(path.join(__dirname, 'fixtures/whitespace.git')) - - let diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceChange: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceChange: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: true}) - expect(diffs.length).toBe(1) - }) - }) - - describe('ignoreAllSpace option', () => { - it('ignores whitespace', () => { - repo = git.open(path.join(__dirname, 'fixtures/whitespace.git')) - - let diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreAllSpace: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreAllSpace: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: false}) - expect(diffs.length).toBe(1) - - diffs = repo.getLineDiffs('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: true}) - expect(diffs.length).toBe(0) - }) - }) - - describe('useIndex options', () => { - it('uses the index version instead of the HEAD version for diffs', () => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - - let diffs = repo.getLineDiffs('a.txt', 'first line is different', {useIndex: true}) - expect(diffs.length).toBe(1) - - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'first line is different', 'utf8') - - const gitCommandHandler = jasmine.createSpy('gitCommandHandler') - execCommands([`cd ${repoDirectory}`, 'git add a.txt'], gitCommandHandler) - - waitsFor(() => gitCommandHandler.callCount === 1) - - runs(() => { - diffs = repo.getLineDiffs('a.txt', 'first line is different', {useIndex: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffs('a.txt', 'first line is different', {useIndex: false}) - expect(diffs.length).toBe(1) - }) - }) - }) - }) - - describe('.getLineDiffDetails(path, text, options)', () => { - it('returns all relevant lines in a diff', () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - - const isOldLine = diff => (diff.oldLineNumber >= 0) && (diff.newLineNumber === -1) - - const isNewLine = diff => (diff.oldLineNumber === -1) && (diff.newLineNumber >= 0) - - let diffs = repo.getLineDiffDetails('a.txt', 'first line is different') - expect(diffs.length).toBe(3) - expect(isOldLine(diffs[0])).toBe(true) - expect(diffs[0].line).toEqual('first line\n') - expect(isNewLine(diffs[1])).toBe(true) - expect(diffs[1].line).toEqual('first line is different') - - diffs = repo.getLineDiffDetails('a.txt', 'first line\nsecond line') - expect(diffs.length).toBe(2) - expect(isNewLine(diffs[0])).toBe(true) - expect(diffs[0].line).toEqual('second line') - - diffs = repo.getLineDiffDetails('a.txt', '') - expect(diffs.length).toBe(1) - expect(isOldLine(diffs[0])).toBe(true) - expect(diffs[0].line).toEqual('first line\n') - }) - - it("returns null for paths that don't exist", () => { - repo = git.open(path.join(__dirname, 'fixtures/master.git')) - - const diffs = repo.getLineDiffDetails('i-dont-exists.txt', 'content') - expect(diffs).toBeNull() - }) - - describe('ignoreSpaceAtEOL option', () => { - it('ignores eol of line whitespace changes', () => { - repo = git.open(path.join(__dirname, 'fixtures/whitespace.git')) - - let diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreEolWhitespace: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreEolWhitespace: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceAtEOL: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceAtEOL: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: true}) - expect(diffs.length).toBe(4) - - diffs = repo.getLineDiffDetails('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceAtEOL: true}) - expect(diffs.length).toBe(6) - }) - }) - - describe('ignoreSpaceChange option', () => { - it('ignores whitespace changes', () => { - repo = git.open(path.join(__dirname, 'fixtures/whitespace.git')) - - let diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceChange: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreSpaceChange: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreSpaceChange: true}) - expect(diffs.length).toBe(2) - }) - }) - - describe('ignoreAllSpace option', () => { - it('ignores whitespace', () => { - repo = git.open(path.join(__dirname, 'fixtures/whitespace.git')) - - let diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreAllSpace: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n second\r\n\tthird\r\n', {ignoreAllSpace: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', 'first\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: false}) - expect(diffs.length).toBe(6) - - diffs = repo.getLineDiffDetails('file.txt', ' \tfirst\r\n \tsecond\r\n \tthird\r\n', {ignoreAllSpace: true}) - expect(diffs.length).toBe(0) - }) - }) - - describe('useIndex options', () => { - it('uses the index version instead of the HEAD version for diffs', () => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - - let diffs = repo.getLineDiffDetails('a.txt', 'first line is different', {useIndex: true}) - expect(diffs.length).toBe(3) - - const filePath = path.join(repo.getWorkingDirectory(), 'a.txt') - fs.writeFileSync(filePath, 'first line is different', 'utf8') - - const gitCommandHandler = jasmine.createSpy('gitCommandHandler') - execCommands([`cd ${repoDirectory}`, 'git add a.txt'], gitCommandHandler) - - waitsFor(() => gitCommandHandler.callCount === 1) - - runs(() => { - diffs = repo.getLineDiffDetails('a.txt', 'first line is different', {useIndex: true}) - expect(diffs.length).toBe(0) - - diffs = repo.getLineDiffDetails('a.txt', 'first line is different', {useIndex: false}) - expect(diffs.length).toBe(3) - }) - }) - }) - }) - - describe('.relativize(path)', () => { - it('relativizes the given path to the working directory of the repository', () => { - repo = git.open(__dirname) - const workingDirectory = repo.getWorkingDirectory() - - expect(repo.relativize(path.join(workingDirectory, 'a.txt'))).toBe('a.txt') - expect(repo.relativize(path.join(workingDirectory, 'a/b/c.txt'))).toBe('a/b/c.txt') - expect(repo.relativize('a.txt')).toBe('a.txt') - expect(repo.relativize('/not/in/working/dir')).toBe('/not/in/working/dir') - expect(repo.relativize(null)).toBe(null) - expect(repo.relativize()).toBeUndefined() - expect(repo.relativize('')).toBe('') - expect(repo.relativize(workingDirectory)).toBe('') - }) - - describe('when the opened path is a symlink', () => { - it('relativizes against both the linked path and the real path', () => { - // Creating symbol link on Windows requires administrator permission so - // we just skip this test. - if (process.platform === 'win32') { return } - - const repoDirectory = fs.realpathSync(temp.mkdirSync('node-git-repo-')) - const linkDirectory = path.join(fs.realpathSync(temp.mkdirSync('node-git-repo-')), 'link') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - fs.symlinkSync(repoDirectory, linkDirectory) - - repo = git.open(linkDirectory) - expect(repo.relativize(path.join(repoDirectory, 'test1'))).toBe('test1') - expect(repo.relativize(path.join(linkDirectory, 'test2'))).toBe('test2') - expect(repo.relativize(path.join(linkDirectory, 'test2/test3'))).toBe('test2/test3') - expect(repo.relativize('test2/test3')).toBe('test2/test3') - }) - }) - - it('handles case insensitive filesystems', () => { - const repoDirectory = temp.mkdirSync('lower-case-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - repo.caseInsensitiveFs = true - const workingDirectory = repo.getWorkingDirectory() - - expect(repo.relativize(path.join(workingDirectory.toUpperCase(), 'a.txt'))).toBe('a.txt') - expect(repo.relativize(path.join(workingDirectory.toUpperCase(), 'a/b/c.txt'))).toBe('a/b/c.txt') - - const linkDirectory = path.join(fs.realpathSync(temp.mkdirSync('lower-case-symlink')), 'link') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - fs.symlinkSync(repoDirectory, linkDirectory) - - repo = git.open(linkDirectory) - repo.caseInsensitiveFs = true - expect(repo.relativize(path.join(linkDirectory.toUpperCase(), 'test2'))).toBe('test2') - expect(repo.relativize(path.join(linkDirectory.toUpperCase(), 'test2/test3'))).toBe('test2/test3') - }) - }) - - describe('.isWorkingDirectory(path)', () => { - it("returns whether the given path is the repository's working directory", () => { - repo = git.open(__dirname) - let workingDirectory = repo.getWorkingDirectory() - - expect(repo.isWorkingDirectory(workingDirectory)).toBe(true) - expect(repo.isWorkingDirectory()).toBe(false) - expect(repo.isWorkingDirectory(null)).toBe(false) - expect(repo.isWorkingDirectory('')).toBe(false) - expect(repo.isWorkingDirectory('test')).toBe(false) - - const repoDirectory = temp.mkdirSync('lower-case-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - repo.caseInsensitiveFs = true - workingDirectory = repo.getWorkingDirectory() - - expect(repo.isWorkingDirectory(workingDirectory.toUpperCase())).toBe(true) - }) - }) - - describe('.submoduleForPath(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - const submoduleDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'master.git'), path.join(repoDirectory, '.git')) - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'master.git'), path.join(submoduleDirectory, '.git')) - - const gitCommandHandler = jasmine.createSpy('gitCommandHandler') - execCommands([`cd ${repoDirectory}`, `git submodule add ${submoduleDirectory} sub`], gitCommandHandler) - - waitsFor(() => gitCommandHandler.callCount === 1) - - runs(() => repo = git.open(repoDirectory)) - }) - - it('returns the repository for the path', () => { - expect(repo.submoduleForPath()).toBe(null) - expect(repo.submoduleForPath(null)).toBe(null) - expect(repo.submoduleForPath('')).toBe(null) - expect(repo.submoduleForPath('sub1')).toBe(null) - - let submoduleRepoPath = path.join(repo.getPath(), 'modules', 'sub/') - if (process.platform === 'win32') { submoduleRepoPath = submoduleRepoPath.replace(/\\/g, '/') } - - expect(repo.submoduleForPath('sub').getPath()).toBe(submoduleRepoPath) - expect(repo.submoduleForPath('sub/').getPath()).toBe(submoduleRepoPath) - expect(repo.submoduleForPath('sub/a').getPath()).toBe(submoduleRepoPath) - expect(repo.submoduleForPath('sub/a/b/c/d').getPath()).toBe(submoduleRepoPath) - }) - }) - - describe('.add(path)', () => { - beforeEach(() => { - const repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/master.git'), path.join(repoDirectory, '.git')) - repo = git.open(repoDirectory) - - const filePath = path.join(repoDirectory, 'toadd.txt') - fs.writeFileSync(filePath, 'changes to stage', 'utf8') - }) - - it('introduces the current state of the file to the index', () => { - expect(repo.getStatus('toadd.txt')).toBe(1 << 7) - repo.add('toadd.txt') - expect(repo.getStatus('toadd.txt')).toBe(1 << 0) - }) - - it("throws an error if the file doesn't exist", () => expect(() => repo.add('missing.txt')).toThrow()) - }) - - it('can handle multiple simultaneous async calls', async () => { - repoDirectory = temp.mkdirSync('node-git-repo-') - wrench.copyDirSyncRecursive( - path.join(__dirname, 'fixtures/subdir.git'), - path.join(repoDirectory, '.git') - ) - repo = git.open(repoDirectory) - - const operations = [ - () => repo.getAheadBehindCountAsync(), - () => repo.getHeadAsync(), - () => repo.getStatusAsync(), - () => repo.getStatusAsync(['*']), - ] - - for (let i = 0; i < 20; i++) { - const promises = [] - for (let j = 0, count = random(100); j < count; j++) { - promises.push(operations[random(operations.length)]()) - } - await Promise.all(promises) - } - - function random (max) { - return Math.floor(Math.random() * max) - } - }) -}) - -function execCommands (commands, callback) { - let command - if (process.platform === 'win32') { - command = commands.join(' & ') - } else { - command = commands.join(' && ') - } - exec(command, callback) -} diff --git a/src/git.js b/src/git.js deleted file mode 100644 index 217e6038..00000000 --- a/src/git.js +++ /dev/null @@ -1,356 +0,0 @@ -const path = require('path') -const fs = require('fs-plus') -const {Repository} = require('../build/Release/git.node') - -const statusIndexNew = 1 << 0 -const statusIndexModified = 1 << 1 -const statusIndexDeleted = 1 << 2 -const statusIndexRenamed = 1 << 3 -const statusIndexTypeChange = 1 << 4 -const statusWorkingDirNew = 1 << 7 -const statusWorkingDirModified = 1 << 8 -const statusWorkingDirDelete = 1 << 9 -const statusWorkingDirTypeChange = 1 << 10 -const statusIgnored = 1 << 14 - -const modifiedStatusFlags = - statusWorkingDirModified | - statusIndexModified | - statusWorkingDirDelete | - statusIndexDeleted | - statusWorkingDirTypeChange | - statusIndexTypeChange - -const newStatusFlags = statusWorkingDirNew | statusIndexNew - -const deletedStatusFlags = statusWorkingDirDelete | statusIndexDeleted - -const indexStatusFlags = - statusIndexNew | - statusIndexModified | - statusIndexDeleted | - statusIndexRenamed | - statusIndexTypeChange - -Repository.prototype.release = function () { - for (let submodulePath in this.submodules) { - const submoduleRepo = this.submodules[submodulePath] - if (submoduleRepo) submoduleRepo.release() - } - return this._release() -} - -Repository.prototype.getWorkingDirectory = function () { - if (!this.workingDirectory) { - this.workingDirectory = this._getWorkingDirectory() - if (this.workingDirectory) this.workingDirectory = this.workingDirectory.replace(/\/$/, '') - } - return this.workingDirectory -} - -Repository.prototype.getShortHead = function () { - const head = this.getHead() - if (head == null) return head - if (head.startsWith('refs/heads/')) return head.substring(11) - if (head.startsWith('refs/tags/')) return head.substring(10) - if (head.startsWith('refs/remotes/')) return head.substring(13) - if (head.match(/[a-fA-F0-9]{40}/)) return head.substring(0, 7) - return head -} - -Repository.prototype.isStatusModified = function (status = 0) { - return (status & modifiedStatusFlags) > 0 -} - -Repository.prototype.isPathModified = function (path) { - return this.isStatusModified(this.getStatus(path)) -} - -Repository.prototype.isStatusNew = function (status = 0) { - return (status & newStatusFlags) > 0 -} - -Repository.prototype.isPathNew = function (path) { - return this.isStatusNew(this.getStatus(path)) -} - -Repository.prototype.isStatusDeleted = function (status = 0) { - return (status & deletedStatusFlags) > 0 -} - -Repository.prototype.isPathDeleted = function (path) { - return this.isStatusDeleted(this.getStatus(path)) -} - -Repository.prototype.isPathStaged = function (path) { - return this.isStatusStaged(this.getStatus(path)) -} - -Repository.prototype.isStatusIgnored = function (status = 0) { - return (status & statusIgnored) > 0 -} - -Repository.prototype.isStatusStaged = function (status = 0) { - return (status & indexStatusFlags) > 0 -} - -Repository.prototype.getUpstreamBranch = function (branch) { - if (branch == null) branch = this.getHead() - if (!branch || !branch.startsWith('refs/heads/')) return null - const shortBranch = branch.substring(11) - - const branchMerge = this.getConfigValue(`branch.${shortBranch}.merge`) - if (!branchMerge || !branchMerge.startsWith('refs/heads/')) return null - const shortBranchMerge = branchMerge.substring(11) - - const branchRemote = this.getConfigValue(`branch.${shortBranch}.remote`) - if (!branch || branch.length === 0) return null - - return `refs/remotes/${branchRemote}/${shortBranchMerge}` -} - -Repository.prototype.getAheadBehindCount = function (branch = 'HEAD') { - if (branch !== 'HEAD' && !branch.startsWith('refs/heads/')) { - branch = `refs/heads/${branch}` - } - - const headCommit = this.getReferenceTarget(branch) - if (!headCommit || headCommit.length === 0) return {ahead: 0, behind: 0} - - const upstream = this.getUpstreamBranch() - if (!upstream || upstream.length === 0) return {ahead: 0, behind: 0} - - const upstreamCommit = this.getReferenceTarget(upstream) - if (!upstreamCommit || upstreamCommit.length === 0) return {ahead: 0, behind: 0} - - return this.compareCommits(headCommit, upstreamCommit) -} - -Repository.prototype.getAheadBehindCountAsync = function (branch = 'HEAD') { - if (branch !== 'HEAD' && !branch.startsWith('refs/heads/')) { - branch = `refs/heads/${branch}` - } - - const headCommit = this.getReferenceTarget(branch) - if (!headCommit || headCommit.length === 0) return {ahead: 0, behind: 0} - - const upstream = this.getUpstreamBranch() - if (!upstream || upstream.length === 0) return {ahead: 0, behind: 0} - - const upstreamCommit = this.getReferenceTarget(upstream) - if (!upstreamCommit || upstreamCommit.length === 0) return {ahead: 0, behind: 0} - - return performAsyncWork(this, done => this.compareCommitsAsync( - done, - headCommit, - upstreamCommit - )) -} - -Repository.prototype.checkoutReference = function (branch, create) { - if (branch.indexOf('refs/heads/') !== 0) branch = `refs/heads/${branch}` - return this.checkoutRef(branch, create) -} - -Repository.prototype.relativize = function (path) { - let workingDirectory - if (!path) return path - - if (process.platform === 'win32') { - path = path.replace(/\\/g, '/') - } else { - if (path[0] !== '/') return path - } - - if (this.caseInsensitiveFs) { - const lowerCasePath = path.toLowerCase() - - workingDirectory = this.getWorkingDirectory() - if (workingDirectory) { - workingDirectory = workingDirectory.toLowerCase() - if (lowerCasePath.startsWith(`${workingDirectory}/`)) { - return path.substring(workingDirectory.length + 1) - } else if (lowerCasePath === workingDirectory) { - return '' - } - } - - if (this.openedWorkingDirectory) { - workingDirectory = this.openedWorkingDirectory.toLowerCase() - if (lowerCasePath.startsWith(`${workingDirectory}/`)) { - return path.substring(workingDirectory.length + 1) - } else if (lowerCasePath === workingDirectory) { - return '' - } - } - } else { - workingDirectory = this.getWorkingDirectory() - if (workingDirectory) { - if (path.startsWith(`${workingDirectory}/`)) { - return path.substring(workingDirectory.length + 1) - } else if (path === workingDirectory) { - return '' - } - } - - if (this.openedWorkingDirectory) { - if (path.startsWith(`${this.openedWorkingDirectory}/`)) { - return path.substring(this.openedWorkingDirectory.length + 1) - } else if (path === this.openedWorkingDirectory) { - return '' - } - } - } - - return path -} - -Repository.prototype.submoduleForPath = function (path) { - path = this.relativize(path) - if (!path) return null - - for (let submodulePath in this.submodules) { - const submoduleRepo = this.submodules[submodulePath] - if (path === submodulePath) { - return submoduleRepo - } else if (path.startsWith(`${submodulePath}/`)) { - path = path.substring(submodulePath.length + 1) - return submoduleRepo.submoduleForPath(path) || submoduleRepo - } - } - - return null -} - -Repository.prototype.isWorkingDirectory = function (path) { - if (!path) return false - - if (process.platform === 'win32') { - path = path.replace(/\\/g, '/') - } else { - if (path[0] !== '/') return false - } - - if (this.caseInsensitiveFs) { - const lowerCasePath = path.toLowerCase() - const workingDirectory = this.getWorkingDirectory() - if (workingDirectory && workingDirectory.toLowerCase() === lowerCasePath) return true - if (this.openedWorkingDirectory && this.openedWorkingDirectory.toLowerCase() === lowerCasePath) return true - } else { - return path === this.getWorkingDirectory() || path === this.openedWorkingDirectory - } - - return false -} - -const {getHeadAsync, getStatus, getStatusAsync, getStatusForPath} = Repository.prototype -delete Repository.prototype.getStatusForPath - -Repository.prototype.getStatusForPaths = function (paths) { - if (paths && paths.length > 0) { - return getStatus.call(this, paths) - } else { - return {} - } -} - -Repository.prototype.getStatus = function (path) { - if (typeof path === 'string') { - return getStatusForPath.call(this, path) - } else { - return getStatus.call(this) - } -} - -Repository.prototype.getHeadAsync = function () { - return performAsyncWork(this, done => getHeadAsync.call(this, done)) -} - -Repository.prototype.getStatusAsync = function () { - return performAsyncWork(this, done => getStatusAsync.call(this, done)) -} - -Repository.prototype.getStatusForPathsAsync = function (paths) { - return performAsyncWork(this, done => getStatusAsync.call(this, done, paths)) -} - -function performAsyncWork (repo, fn) { - fn = promisify(fn) - - if (repo._lastAsyncPromise) { - repo._lastAsyncPromise = repo._lastAsyncPromise.then(fn, fn) - } else { - repo._lastAsyncPromise = fn() - } - return repo._lastAsyncPromise -} - -function promisify (fn) { - return () => new Promise((resolve, reject) => - fn((error, result) => error ? reject(error) : resolve(result)) - ) -} - -function realpath (unrealPath) { - try { - return fs.realpathSync(unrealPath) - } catch (e) { - return unrealPath - } -} - -function isRootPath (repositoryPath) { - if (process.platform === 'win32') { - return /^[a-zA-Z]+:[\\/]$/.test(repositoryPath) - } else { - return repositoryPath === path.sep - } -} - -function openRepository (repositoryPath, search) { - const symlink = realpath(repositoryPath) !== repositoryPath - - if (process.platform === 'win32') repositoryPath = repositoryPath.replace(/\\/g, '/') - const repository = new Repository(repositoryPath, search) - if (repository.exists()) { - repository.caseInsensitiveFs = fs.isCaseInsensitive() - if (symlink) { - const workingDirectory = repository.getWorkingDirectory() - while (!isRootPath(repositoryPath)) { - if (realpath(repositoryPath) === workingDirectory) { - repository.openedWorkingDirectory = repositoryPath - break - } - repositoryPath = path.resolve(repositoryPath, '..') - } - } - return repository - } else { - return null - } -} - -function openSubmodules (repository) { - repository.submodules = {} - - for (let relativePath of repository.getSubmodulePaths()) { - if (relativePath) { - const submodulePath = path.join(repository.getWorkingDirectory(), relativePath) - const submoduleRepo = openRepository(submodulePath, false) - if (submoduleRepo) { - if (submoduleRepo.getPath() === repository.getPath()) { - submoduleRepo.release() - } else { - openSubmodules(submoduleRepo) - repository.submodules[relativePath] = submoduleRepo - } - } - } - } -} - -exports.open = function (repositoryPath, search = true) { - const repository = openRepository(repositoryPath, search) - if (repository) openSubmodules(repository) - return repository -} diff --git a/src/repository.cc b/src/repository.cc deleted file mode 100644 index fb995f05..00000000 --- a/src/repository.cc +++ /dev/null @@ -1,1125 +0,0 @@ -// Copyright (c) 2013 GitHub Inc. -// -// 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. - -#include "repository.h" -#include -#include -#include - -void Repository::Init(Local target) { - Nan::HandleScope scope; - git_libgit2_init(); - - Local newTemplate = Nan::New( - Repository::New); - newTemplate->SetClassName(Nan::New("Repository").ToLocalChecked()); - newTemplate->InstanceTemplate()->SetInternalFieldCount(1); - - Local proto = newTemplate->PrototypeTemplate(); - Nan::SetMethod(proto, "getPath", Repository::GetPath); - Nan::SetMethod(proto, "_getWorkingDirectory", - Repository::GetWorkingDirectory); - Nan::SetMethod(proto, "exists", Repository::Exists); - Nan::SetMethod(proto, "getSubmodulePaths", Repository::GetSubmodulePaths); - Nan::SetMethod(proto, "getHead", Repository::GetHead); - Nan::SetMethod(proto, "getHeadAsync", Repository::GetHeadAsync); - Nan::SetMethod(proto, "refreshIndex", Repository::RefreshIndex); - Nan::SetMethod(proto, "isIgnored", Repository::IsIgnored); - Nan::SetMethod(proto, "isSubmodule", Repository::IsSubmodule); - Nan::SetMethod(proto, "getConfigValue", Repository::GetConfigValue); - Nan::SetMethod(proto, "setConfigValue", Repository::SetConfigValue); - Nan::SetMethod(proto, "getStatus", Repository::GetStatus); - Nan::SetMethod(proto, "getStatusForPath", Repository::GetStatusForPath); - Nan::SetMethod(proto, "getStatusAsync", Repository::GetStatusAsync); - Nan::SetMethod(proto, "checkoutHead", Repository::CheckoutHead); - Nan::SetMethod(proto, "getReferenceTarget", Repository::GetReferenceTarget); - Nan::SetMethod(proto, "getDiffStats", Repository::GetDiffStats); - Nan::SetMethod(proto, "getIndexBlob", Repository::GetIndexBlob); - Nan::SetMethod(proto, "getHeadBlob", Repository::GetHeadBlob); - Nan::SetMethod(proto, "compareCommits", Repository::CompareCommits); - Nan::SetMethod(proto, "compareCommitsAsync", Repository::CompareCommitsAsync); - Nan::SetMethod(proto, "_release", Repository::Release); - Nan::SetMethod(proto, "getLineDiffs", Repository::GetLineDiffs); - Nan::SetMethod(proto, "getLineDiffDetails", Repository::GetLineDiffDetails); - Nan::SetMethod(proto, "getReferences", Repository::GetReferences); - Nan::SetMethod(proto, "checkoutRef", Repository::CheckoutReference); - Nan::SetMethod(proto, "add", Repository::Add); - - Nan::Set(target, - Nan::New("Repository").ToLocalChecked(), - Nan::GetFunction(newTemplate).ToLocalChecked()); -} - -NODE_MODULE(git, Repository::Init) - -NAN_METHOD(Repository::New) { - Nan::HandleScope scope; - Repository* repository = new Repository( - Local::Cast(info[0]), Local::Cast(info[1])); - repository->Wrap(info.This()); - info.GetReturnValue().SetUndefined(); -} - -git_repository* Repository::GetRepository(Nan::NAN_METHOD_ARGS_TYPE args) { - return Nan::ObjectWrap::Unwrap(args.This())->repository; -} - -git_repository* Repository::GetAsyncRepository(Nan::NAN_METHOD_ARGS_TYPE args) { - return Nan::ObjectWrap::Unwrap(args.This())->async_repository; -} - -int Repository::GetBlob(Nan::NAN_METHOD_ARGS_TYPE args, - git_repository* repo, git_blob*& blob) { - std::string path(*Nan::Utf8String(args[0])); - - int useIndex = false; - if (args.Length() >= 3) { - Local optionsArg(Local::Cast(args[2])); - if (Nan::To(Nan::Get(optionsArg, Nan::New("useIndex").ToLocalChecked()).ToLocalChecked()).FromJust()) - useIndex = true; - } - - if (useIndex) { - git_index* index; - if (git_repository_index(&index, repo) != GIT_OK) - return -1; - - git_index_read(index, 0); - const git_index_entry* entry = git_index_get_bypath(index, path.data(), 0); - if (entry == NULL) { - git_index_free(index); - return -1; - } - - const git_oid* blobSha = &entry->id; - if (blobSha != NULL && git_blob_lookup(&blob, repo, blobSha) != GIT_OK) - blob = NULL; - } else { - git_reference* head; - if (git_repository_head(&head, repo) != GIT_OK) - return -1; - - const git_oid* sha = git_reference_target(head); - git_commit* commit; - int commitStatus = git_commit_lookup(&commit, repo, sha); - git_reference_free(head); - if (commitStatus != GIT_OK) - return -1; - - git_tree* tree; - int treeStatus = git_commit_tree(&tree, commit); - git_commit_free(commit); - if (treeStatus != GIT_OK) - return -1; - - git_tree_entry* treeEntry; - if (git_tree_entry_bypath(&treeEntry, tree, path.c_str()) != GIT_OK) { - git_tree_free(tree); - return -1; - } - - const git_oid* blobSha = git_tree_entry_id(treeEntry); - if (blobSha != NULL && git_blob_lookup(&blob, repo, blobSha) != GIT_OK) - blob = NULL; - git_tree_entry_free(treeEntry); - git_tree_free(tree); - } - - if (blob == NULL) - return -1; - - return 0; -} - -// C++ equivalent to GIT_DIFF_OPTIONS_INIT, we can not use it directly because -// of C++'s strong typing. -git_diff_options Repository::CreateDefaultGitDiffOptions() { - git_diff_options options = { 0 }; - options.version = GIT_DIFF_OPTIONS_VERSION; - options.context_lines = 3; - return options; -} - -NAN_METHOD(Repository::Exists) { - Nan::HandleScope scope; - - info.GetReturnValue().Set(Nan::New(GetRepository(info) != NULL)); -} - -NAN_METHOD(Repository::GetPath) { - Nan::HandleScope scope; - git_repository* repository = GetRepository(info); - const char* path = git_repository_path(repository); - - info.GetReturnValue().Set(Nan::New(path).ToLocalChecked()); -} - -NAN_METHOD(Repository::GetWorkingDirectory) { - Nan::HandleScope scope; - git_repository* repository = GetRepository(info); - const char* path = git_repository_workdir(repository); - info.GetReturnValue().Set(Nan::New(path).ToLocalChecked()); -} - -NAN_METHOD(Repository::GetSubmodulePaths) { - Nan::HandleScope scope; - git_repository* repository = GetRepository(info); - std::vector paths; - git_submodule_foreach(repository, SubmoduleCallback, &paths); - Local v8Paths = Nan::New(paths.size()); - for (size_t i = 0; i < paths.size(); i++) - Nan::Set(v8Paths, i, Nan::New(paths[i].data()).ToLocalChecked()); - info.GetReturnValue().Set(v8Paths); -} - -class HeadWorker { - git_repository *repository; - std::string result; - - public: - void Execute() { - git_reference *head; - if (git_repository_head(&head, repository) != GIT_OK) return; - - if (git_repository_head_detached(repository) == 1) { - const git_oid *oid = git_reference_target(head); - if (oid) { - result.resize(GIT_OID_HEXSZ); - git_oid_tostr(&result[0], GIT_OID_HEXSZ + 1, oid); - } - } else { - result = git_reference_name(head); - } - - git_reference_free(head); - } - - std::pair, Local> Finish() { - if (result.empty()) { - return {Nan::Null(), Nan::Null()}; - } else { - return {Nan::Null(), Nan::New(result).ToLocalChecked()}; - } - } - - HeadWorker(git_repository *repository) : repository(repository) {} -}; - -NAN_METHOD(Repository::GetHead) { - HeadWorker worker(GetRepository(info)); - worker.Execute(); - info.GetReturnValue().Set(worker.Finish().second); -} - -NAN_METHOD(Repository::GetHeadAsync) { - class HeadAsyncWorker : public Nan::AsyncWorker { - HeadWorker worker; - - public: - void Execute () { worker.Execute(); } - - void HandleOKCallback() { - auto result = worker.Finish(); - Local argv[] = {result.first, result.second}; - callback->Call(2, argv); - } - - HeadAsyncWorker(Nan::Callback *callback, git_repository *repository) : Nan::AsyncWorker(callback), worker(repository) {} - }; - - auto callback = new Nan::Callback(Local::Cast(info[0])); - Nan::AsyncQueueWorker(new HeadAsyncWorker(callback, GetAsyncRepository(info))); -} - -NAN_METHOD(Repository::RefreshIndex) { - Nan::HandleScope scope; - git_repository* repository = GetRepository(info); - git_index* index; - if (git_repository_index(&index, repository) == GIT_OK) { - git_index_read(index, 0); - git_index_free(index); - } - info.GetReturnValue().SetUndefined(); -} - -NAN_METHOD(Repository::IsIgnored) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::New(false)); - - git_repository* repository = GetRepository(info); - std::string path(*Nan::Utf8String(info[0])); - int ignored; - if (git_ignore_path_is_ignored(&ignored, - repository, - path.c_str()) == GIT_OK) - return info.GetReturnValue().Set(Nan::New(ignored == 1)); - else - return info.GetReturnValue().Set(Nan::New(false)); -} - -NAN_METHOD(Repository::IsSubmodule) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::New(false)); - - git_index* index; - git_repository* repository = GetRepository(info); - if (git_repository_index(&index, repository) == GIT_OK) { - std::string path(*Nan::Utf8String(info[0])); - const git_index_entry* entry = git_index_get_bypath(index, path.c_str(), 0); - Local isSubmodule = Nan::New( - entry != NULL && (entry->mode & S_IFMT) == GIT_FILEMODE_COMMIT); - git_index_free(index); - return info.GetReturnValue().Set(isSubmodule); - } else { - return info.GetReturnValue().Set(Nan::New(false)); - } -} - -NAN_METHOD(Repository::GetConfigValue) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::Null()); - - git_config* config; - git_repository* repository = GetRepository(info); - if (git_repository_config_snapshot(&config, repository) != GIT_OK) - return info.GetReturnValue().Set(Nan::Null()); - - std::string configKey(*Nan::Utf8String(info[0])); - const char* configValue; - if (git_config_get_string( - &configValue, config, configKey.c_str()) == GIT_OK) { - git_config_free(config); - return info.GetReturnValue().Set(Nan::New(configValue) - .ToLocalChecked()); - } else { - git_config_free(config); - return info.GetReturnValue().Set(Nan::Null()); - } -} - -NAN_METHOD(Repository::SetConfigValue) { - Nan::HandleScope scope; - if (info.Length() != 2) - return info.GetReturnValue().Set(Nan::New(false)); - - git_config* config; - git_repository* repository = GetRepository(info); - if (git_repository_config(&config, repository) != GIT_OK) - return info.GetReturnValue().Set(Nan::New(false)); - - std::string configKey(*Nan::Utf8String(info[0])); - std::string configValue(*Nan::Utf8String(info[1])); - - int errorCode = git_config_set_string( - config, configKey.c_str(), configValue.c_str()); - git_config_free(config); - return info.GetReturnValue().Set(Nan::New(errorCode == GIT_OK)); -} - -static int StatusCallback(const char* path, unsigned int status, void* payload) { - auto statuses = static_cast *>(payload); - statuses->insert(std::make_pair(std::string(path), status)); - return GIT_OK; -} - -class StatusWorker { - git_repository *repository; - std::map statuses; - char **paths; - unsigned path_count; - int code; - - public: - void Execute() { - git_status_options options = GIT_STATUS_OPTIONS_INIT; - options.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS; - if (paths) { - options.pathspec.count = path_count; - options.pathspec.strings = paths; - } - code = git_status_foreach_ext(repository, &options, StatusCallback, &statuses); - if (paths) { - git_strarray_free(&options.pathspec); - } - } - - std::pair, Local> Finish() { - if (code == GIT_OK) { - Local result = Nan::New(); - for (auto iter = statuses.begin(), end = statuses.end(); iter != end; ++iter) { - Nan::Set( - result, - Nan::New(iter->first.c_str()).ToLocalChecked(), - Nan::New(iter->second) - ); - } - return {Nan::Null(), result}; - } else { - return {Nan::Error("Git status failed"), Nan::Null()}; - } - } - - StatusWorker(git_repository *repository, Local path_filter) : repository{repository} { - if (path_filter->IsArray()) { - Local js_paths = Local::Cast(path_filter); - path_count = js_paths->Length(); - paths = reinterpret_cast(malloc(path_count * sizeof(char *))); - for (unsigned i = 0; i < path_count; i++) { - Nan::Utf8String js_path(Nan::Get(js_paths, i).ToLocalChecked()); - paths[i] = reinterpret_cast(malloc(js_path.length() + 1)); - strcpy(paths[i], *js_path); - } - } else { - paths = NULL; - path_count = 0; - } - } -}; - -NAN_METHOD(Repository::GetStatusAsync) { - class StatusAsyncWorker : public Nan::AsyncWorker { - StatusWorker worker; - - public: - void Execute() { - worker.Execute(); - } - - void HandleOKCallback() { - auto result = worker.Finish(); - Local argv[] = {result.first, result.second}; - callback->Call(2, argv); - } - - StatusAsyncWorker(Nan::Callback *callback, git_repository *repository, Local path_filter) - : Nan::AsyncWorker(callback), worker(repository, path_filter) {} - }; - - auto callback = new Nan::Callback(Local::Cast(info[0])); - Local path_filter = info.Length() > 1 ? info[1] : Local::Cast(Nan::Null()); - Nan::AsyncQueueWorker(new StatusAsyncWorker(callback, GetAsyncRepository(info), path_filter)); -} - -NAN_METHOD(Repository::GetStatus) { - Local path_filter = info.Length() > 0 ? info[0] : Local::Cast(Nan::Null()); - StatusWorker worker(GetRepository(info), path_filter); - worker.Execute(); - auto result = worker.Finish(); - if (result.first->IsNull()) { - info.GetReturnValue().Set(worker.Finish().second); - } else { - info.GetReturnValue().Set(Nan::New()); - } -} - -NAN_METHOD(Repository::GetStatusForPath) { - git_repository* repository = GetRepository(info); - Nan::Utf8String path(info[0]); - unsigned int status = 0; - if (git_status_file(&status, repository, *path) == GIT_OK) - return info.GetReturnValue().Set(Nan::New(status)); - else - return info.GetReturnValue().Set(Nan::New(0)); -} - -NAN_METHOD(Repository::CheckoutHead) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::New(false)); - - Nan::Utf8String utf8Path(info[0]); - char* path = *utf8Path; - - git_checkout_options options = GIT_CHECKOUT_OPTIONS_INIT; - options.checkout_strategy = GIT_CHECKOUT_FORCE | - GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH; - git_strarray paths; - paths.count = 1; - paths.strings = &path; - options.paths = paths; - - int result = git_checkout_head(GetRepository(info), &options); - return info.GetReturnValue().Set(Nan::New(result == GIT_OK)); -} - -NAN_METHOD(Repository::GetReferenceTarget) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::Null()); - - std::string refName(*Nan::Utf8String(info[0])); - git_oid sha; - if (git_reference_name_to_id( - &sha, GetRepository(info), refName.c_str()) == GIT_OK) { - char oid[GIT_OID_HEXSZ + 1]; - git_oid_tostr(oid, GIT_OID_HEXSZ + 1, &sha); - return info.GetReturnValue().Set(Nan::New(oid, -1) - .ToLocalChecked()); - } else { - return info.GetReturnValue().Set(Nan::Null()); - } -} - -NAN_METHOD(Repository::GetDiffStats) { - Nan::HandleScope scope; - - int added = 0; - int deleted = 0; - Local result = Nan::New(); - Nan::Set(result, - Nan::New("added").ToLocalChecked(), - Nan::New(added)); - Nan::Set(result, - Nan::New("deleted").ToLocalChecked(), - Nan::New(deleted)); - - if (info.Length() < 1) - return info.GetReturnValue().Set(result); - - git_repository* repository = GetRepository(info); - git_reference* head; - if (git_repository_head(&head, repository) != GIT_OK) - return info.GetReturnValue().Set(result); - - const git_oid* sha = git_reference_target(head); - git_commit* commit; - int commitStatus = git_commit_lookup(&commit, repository, sha); - git_reference_free(head); - if (commitStatus != GIT_OK) - return info.GetReturnValue().Set(result); - - git_tree* tree; - int treeStatus = git_commit_tree(&tree, commit); - git_commit_free(commit); - if (treeStatus != GIT_OK) - return info.GetReturnValue().Set(result); - - Nan::Utf8String utf8Path(info[0]); - char* path = *utf8Path; - - git_diff_options options = CreateDefaultGitDiffOptions(); - git_strarray paths; - paths.count = 1; - paths.strings = &path; - options.pathspec = paths; - options.context_lines = 0; - options.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH; - - git_diff* diffs; - int diffStatus = git_diff_tree_to_workdir(&diffs, repository, tree, &options); - git_tree_free(tree); - if (diffStatus != GIT_OK) - return info.GetReturnValue().Set(result); - - int deltas = git_diff_num_deltas(diffs); - if (deltas != 1) { - git_diff_free(diffs); - return info.GetReturnValue().Set(result); - } - - git_patch* patch; - int patchStatus = git_patch_from_diff(&patch, diffs, 0); - git_diff_free(diffs); - if (patchStatus != GIT_OK) - return info.GetReturnValue().Set(result); - - int hunks = git_patch_num_hunks(patch); - for (int i = 0; i < hunks; i++) { - int lines = git_patch_num_lines_in_hunk(patch, i); - for (int j = 0; j < lines; j++) { - const git_diff_line* line; - if (git_patch_get_line_in_hunk(&line, patch, i, j) == GIT_OK) { - switch (line->origin) { - case GIT_DIFF_LINE_ADDITION: - added++; - break; - case GIT_DIFF_LINE_DELETION: - deleted++; - break; - } - } - } - } - git_patch_free(patch); - - Nan::Set(result, - Nan::New("added").ToLocalChecked(), - Nan::New(added)); - Nan::Set(result, - Nan::New("deleted").ToLocalChecked(), - Nan::New(deleted)); - - return info.GetReturnValue().Set(result); -} - -NAN_METHOD(Repository::GetHeadBlob) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::Null()); - - std::string path(*Nan::Utf8String(info[0])); - - git_repository* repo = GetRepository(info); - git_reference* head; - if (git_repository_head(&head, repo) != GIT_OK) - return info.GetReturnValue().Set(Nan::Null()); - - const git_oid* sha = git_reference_target(head); - git_commit* commit; - int commitStatus = git_commit_lookup(&commit, repo, sha); - git_reference_free(head); - if (commitStatus != GIT_OK) - return info.GetReturnValue().Set(Nan::Null()); - - git_tree* tree; - int treeStatus = git_commit_tree(&tree, commit); - git_commit_free(commit); - if (treeStatus != GIT_OK) - return info.GetReturnValue().Set(Nan::Null()); - - git_tree_entry* treeEntry; - if (git_tree_entry_bypath(&treeEntry, tree, path.c_str()) != GIT_OK) { - git_tree_free(tree); - return info.GetReturnValue().Set(Nan::Null()); - } - - git_blob* blob = NULL; - const git_oid* blobSha = git_tree_entry_id(treeEntry); - if (blobSha != NULL && git_blob_lookup(&blob, repo, blobSha) != GIT_OK) - blob = NULL; - git_tree_entry_free(treeEntry); - git_tree_free(tree); - if (blob == NULL) - return info.GetReturnValue().Set(Nan::Null()); - - const char* content = static_cast(git_blob_rawcontent(blob)); - Local value = Nan::New(content).ToLocalChecked(); - git_blob_free(blob); - return info.GetReturnValue().Set(value); -} - -NAN_METHOD(Repository::GetIndexBlob) { - Nan::HandleScope scope; - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::Null()); - - std::string path(*Nan::Utf8String(info[0])); - - git_repository* repo = GetRepository(info); - git_index* index; - if (git_repository_index(&index, repo) != GIT_OK) - return info.GetReturnValue().Set(Nan::Null()); - - git_index_read(index, 0); - const git_index_entry* entry = git_index_get_bypath(index, path.data(), 0); - if (entry == NULL) { - git_index_free(index); - return info.GetReturnValue().Set(Nan::Null()); - } - - git_blob* blob = NULL; - const git_oid* blobSha = &entry->id; - if (blobSha != NULL && git_blob_lookup(&blob, repo, blobSha) != GIT_OK) - blob = NULL; - git_index_free(index); - if (blob == NULL) - return info.GetReturnValue().Set(Nan::Null()); - - const char* content = static_cast(git_blob_rawcontent(blob)); - Local value = Nan::New(content).ToLocalChecked(); - git_blob_free(blob); - return info.GetReturnValue().Set(value); -} - -int Repository::SubmoduleCallback( - git_submodule* submodule, const char* name, void* payload) { - std::vector* submodules = - static_cast*>(payload); - const char* submodulePath = git_submodule_path(submodule); - if (submodulePath != NULL) - submodules->push_back(submodulePath); - return GIT_OK; -} - -NAN_METHOD(Repository::Release) { - Nan::HandleScope scope; - Repository* repo = Nan::ObjectWrap::Unwrap(info.This()); - if (repo->repository != NULL) { - git_repository_free(repo->repository); - repo->repository = NULL; - } - info.GetReturnValue().SetUndefined(); -} - -unsigned GetCommitCount(git_repository *repository, git_oid *left_oid, git_oid *right_oid) { - git_revwalk *revwalk; - if (git_revwalk_new(&revwalk, repository) != GIT_OK) return 0; - - git_revwalk_push(revwalk, left_oid); - git_revwalk_hide(revwalk, right_oid); - - unsigned result = 0; - git_oid current_commit; - while (git_revwalk_next(¤t_commit, revwalk) == GIT_OK) result++; - git_revwalk_free(revwalk); - - return result; -} - -class CompareCommitsWorker { - git_repository *repository; - std::string left_id; - std::string right_id; - unsigned ahead_count; - unsigned behind_count; - - public: - void Execute() { - git_oid left_oid; - if (git_oid_fromstr(&left_oid, left_id.c_str()) != GIT_OK) return; - - git_oid right_oid; - if (git_oid_fromstr(&right_oid, right_id.c_str()) != GIT_OK) return; - - git_oid merge_base; - if (git_merge_base(&merge_base, repository, &left_oid, &right_oid) != GIT_OK) return; - - ahead_count = GetCommitCount(repository, &left_oid, &merge_base); - behind_count = GetCommitCount(repository, &right_oid, &merge_base); - } - - std::pair, Local> Finish() { - Local result = Nan::New(); - Nan::Set(result, Nan::New("ahead").ToLocalChecked(), Nan::New(ahead_count)); - Nan::Set(result, Nan::New("behind").ToLocalChecked(), Nan::New(behind_count)); - return {Nan::Null(), result}; - } - - CompareCommitsWorker(git_repository *repository, Local js_left_id, - Local js_right_id) : repository(repository) { - left_id = *Nan::Utf8String(js_left_id); - right_id = *Nan::Utf8String(js_right_id); - } -}; - -NAN_METHOD(Repository::CompareCommits) { - if (info.Length() < 2) { - info.GetReturnValue().Set(Nan::Null()); - return; - } - - CompareCommitsWorker worker(GetRepository(info), info[0], info[1]); - worker.Execute(); - info.GetReturnValue().Set(worker.Finish().second); -} - -NAN_METHOD(Repository::CompareCommitsAsync) { - class CompareCommitsAsyncWorker : public Nan::AsyncWorker { - CompareCommitsWorker worker; - - public: - void Execute() { - worker.Execute(); - } - - void HandleOKCallback() { - auto result = worker.Finish(); - Local argv[] = {result.first, result.second}; - callback->Call(2, argv); - } - - CompareCommitsAsyncWorker(Nan::Callback *callback, git_repository *repository, - Local js_left_id, Local js_right_id) - : Nan::AsyncWorker(callback), worker(repository, js_left_id, js_right_id) {} - }; - - if (info.Length() < 2) { - info.GetReturnValue().Set(Nan::Null()); - return; - } - - auto callback = new Nan::Callback(Local::Cast(info[0])); - Nan::AsyncQueueWorker(new CompareCommitsAsyncWorker(callback, GetAsyncRepository(info), info[1], info[2])); -} - -int Repository::DiffHunkCallback(const git_diff_delta* delta, - const git_diff_hunk* range, - void* payload) { - std::vector* ranges = - static_cast*>(payload); - ranges->push_back(*range); - return GIT_OK; -} - -NAN_METHOD(Repository::GetLineDiffs) { - Nan::HandleScope scope; - if (info.Length() < 2) - return info.GetReturnValue().Set(Nan::Null()); - - std::string text(*Nan::Utf8String(info[1])); - - git_repository* repo = GetRepository(info); - - git_blob* blob = NULL; - - int getBlobResult = GetBlob(info, repo, blob); - - if (getBlobResult != 0) - return info.GetReturnValue().Set(Nan::Null()); - - std::vector ranges; - git_diff_options options = CreateDefaultGitDiffOptions(); - - if (info.Length() >= 3) { - Local optionsArg(Local::Cast(info[2])); - // Set GIT_DIFF_IGNORE_WHITESPACE when ignoreWhitespace: true - if (Nan::To(Nan::Get(optionsArg, Nan::New("ignoreAllSpace").ToLocalChecked()).ToLocalChecked()).FromJust()) - options.flags = GIT_DIFF_IGNORE_WHITESPACE; - // Set GIT_DIFF_IGNORE_WHITESPACE_CHANGE when ignoreWhitespaceChange: true - else if (Nan::To(Nan::Get(optionsArg, Nan::New("ignoreSpaceChange").ToLocalChecked()).ToLocalChecked()).FromJust()) - options.flags = GIT_DIFF_IGNORE_WHITESPACE_CHANGE; - // Set GIT_DIFF_IGNORE_WHITESPACE_EOL when ignoreEolWhitespace: true - else if (Nan::To(Nan::Get(optionsArg, Nan::New("ignoreSpaceAtEOL").ToLocalChecked()).ToLocalChecked()).FromJust() - || Nan::To(Nan::Get(optionsArg, Nan::New("ignoreEolWhitespace").ToLocalChecked()).ToLocalChecked()).FromJust()) - options.flags = GIT_DIFF_IGNORE_WHITESPACE_EOL; - // Set GIT_DIFF_NORMAL when none of the above are defined - else - options.flags = GIT_DIFF_NORMAL; - } - - options.context_lines = 0; - if (git_diff_blob_to_buffer(blob, NULL, text.data(), text.length(), NULL, - &options, NULL, NULL, DiffHunkCallback, NULL, - &ranges) == GIT_OK) { - Local v8Ranges = Nan::New(ranges.size()); - for (size_t i = 0; i < ranges.size(); i++) { - Local v8Range = Nan::New(); - Nan::Set(v8Range, - Nan::New("oldStart").ToLocalChecked(), - Nan::New(ranges[i].old_start)); - Nan::Set(v8Range, - Nan::New("oldLines").ToLocalChecked(), - Nan::New(ranges[i].old_lines)); - Nan::Set(v8Range, - Nan::New("newStart").ToLocalChecked(), - Nan::New(ranges[i].new_start)); - Nan::Set(v8Range, - Nan::New("newLines").ToLocalChecked(), - Nan::New(ranges[i].new_lines)); - Nan::Set(v8Ranges, i, v8Range); - } - git_blob_free(blob); - return info.GetReturnValue().Set(v8Ranges); - } else { - git_blob_free(blob); - return info.GetReturnValue().Set(Nan::Null()); - } -} - -struct LineDiff { - git_diff_hunk hunk; - git_diff_line line; -}; - -int Repository::DiffLineCallback(const git_diff_delta* delta, - const git_diff_hunk* range, - const git_diff_line* line, - void* payload) { - LineDiff lineDiff; - lineDiff.hunk = *range; - lineDiff.line = *line; - std::vector * lineDiffs = - static_cast*>(payload); - lineDiffs->push_back(lineDiff); - return GIT_OK; -} - -NAN_METHOD(Repository::GetLineDiffDetails) { - Nan::HandleScope scope; - if (info.Length() < 2) - return info.GetReturnValue().Set(Nan::Null()); - - std::string text(*Nan::Utf8String(info[1])); - - git_repository* repo = GetRepository(info); - - git_blob* blob = NULL; - - int getBlobResult = GetBlob(info, repo, blob); - - if (getBlobResult != 0) - return info.GetReturnValue().Set(Nan::Null()); - - std::vector lineDiffs; - git_diff_options options = CreateDefaultGitDiffOptions(); - - if (info.Length() >= 3) { - Local optionsArg(Local::Cast(info[2])); - // Set GIT_DIFF_IGNORE_WHITESPACE when ignoreWhitespace: true - if (Nan::To(Nan::Get(optionsArg, Nan::New("ignoreAllSpace").ToLocalChecked()).ToLocalChecked()).FromJust()) - options.flags = GIT_DIFF_IGNORE_WHITESPACE; - // Set GIT_DIFF_IGNORE_WHITESPACE_CHANGE when ignoreWhitespaceChange: true - else if (Nan::To(Nan::Get(optionsArg, Nan::New("ignoreSpaceChange").ToLocalChecked()).ToLocalChecked()).FromJust()) - options.flags = GIT_DIFF_IGNORE_WHITESPACE_CHANGE; - // Set GIT_DIFF_IGNORE_WHITESPACE_EOL when ignoreEolWhitespace: true - else if (Nan::To(Nan::Get(optionsArg, Nan::New("ignoreSpaceAtEOL").ToLocalChecked()).ToLocalChecked()).FromJust() - || Nan::To(Nan::Get(optionsArg, Nan::New("ignoreEolWhitespace").ToLocalChecked()).ToLocalChecked()).FromJust()) - options.flags = GIT_DIFF_IGNORE_WHITESPACE_EOL; - // Set GIT_DIFF_NORMAL when none of the above are defined - else - options.flags = GIT_DIFF_NORMAL; - } - - options.context_lines = 0; - if (git_diff_blob_to_buffer(blob, NULL, text.data(), text.length(), NULL, - &options, NULL, NULL, NULL, DiffLineCallback, - &lineDiffs) == GIT_OK) { - Local v8Ranges = Nan::New(lineDiffs.size()); - for (size_t i = 0; i < lineDiffs.size(); i++) { - Local v8Range = Nan::New(); - - Nan::Set(v8Range, - Nan::New("oldLineNumber").ToLocalChecked(), - Nan::New(lineDiffs[i].line.old_lineno)); - Nan::Set(v8Range, - Nan::New("newLineNumber").ToLocalChecked(), - Nan::New(lineDiffs[i].line.new_lineno)); - Nan::Set(v8Range, - Nan::New("oldStart").ToLocalChecked(), - Nan::New(lineDiffs[i].hunk.old_start)); - Nan::Set(v8Range, - Nan::New("newStart").ToLocalChecked(), - Nan::New(lineDiffs[i].hunk.new_start)); - Nan::Set(v8Range, - Nan::New("oldLines").ToLocalChecked(), - Nan::New(lineDiffs[i].hunk.old_lines)); - Nan::Set(v8Range, - Nan::New("newLines").ToLocalChecked(), - Nan::New(lineDiffs[i].hunk.new_lines)); - Nan::Set(v8Range, - Nan::New("line").ToLocalChecked(), - Nan::New(lineDiffs[i].line.content, - lineDiffs[i].line.content_len) - .ToLocalChecked()); - - Nan::Set(v8Ranges, i, v8Range); - } - git_blob_free(blob); - return info.GetReturnValue().Set(v8Ranges); - } else { - git_blob_free(blob); - return info.GetReturnValue().Set(Nan::Null()); - } -} - -Local Repository::ConvertStringVectorToV8Array( - const std::vector& vector) { - size_t i = 0, size = vector.size(); - Local array = Nan::New(size); - for (i = 0; i < size; i++) - Nan::Set(array, i, Nan::New(vector[i].c_str()).ToLocalChecked()); - - return array; -} - -NAN_METHOD(Repository::GetReferences) { - Nan::HandleScope scope; - - Local references = Nan::New(); - std::vector heads, remotes, tags; - - git_strarray strarray; - git_reference_list(&strarray, GetRepository(info)); - - for (unsigned int i = 0; i < strarray.count; i++) - if (strncmp(strarray.strings[i], "refs/heads/", 11) == 0) - heads.push_back(strarray.strings[i]); - else if (strncmp(strarray.strings[i], "refs/remotes/", 13) == 0) - remotes.push_back(strarray.strings[i]); - else if (strncmp(strarray.strings[i], "refs/tags/", 10) == 0) - tags.push_back(strarray.strings[i]); - - git_strarray_free(&strarray); - - Nan::Set(references, - Nan::New("heads").ToLocalChecked(), - ConvertStringVectorToV8Array(heads)); - Nan::Set(references, - Nan::New("remotes").ToLocalChecked(), - ConvertStringVectorToV8Array(remotes)); - Nan::Set(references, - Nan::New("tags").ToLocalChecked(), - ConvertStringVectorToV8Array(tags)); - - info.GetReturnValue().Set(references); -} - -int branch_checkout(git_repository* repo, const char* refName) { - git_reference* ref = NULL; - git_object* git_obj = NULL; - git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; - opts.checkout_strategy = GIT_CHECKOUT_SAFE; - int success = -1; - - if (!(success = git_reference_lookup(&ref, repo, refName)) && - !(success = git_reference_peel(&git_obj, ref, GIT_OBJ_TREE)) && - !(success = git_checkout_tree(repo, git_obj, &opts))) - success = git_repository_set_head(repo, refName); - - git_object_free(git_obj); - git_obj = NULL; - git_reference_free(ref); - ref = NULL; - - return success; -} - -NAN_METHOD(Repository::CheckoutReference) { - Nan::HandleScope scope; - - if (info.Length() < 1) - return info.GetReturnValue().Set(Nan::New(false)); - - bool shouldCreateNewRef; - if (info.Length() > 1 && Nan::To(info[1]).FromJust()) - shouldCreateNewRef = true; - else - shouldCreateNewRef = false; - - std::string strRefName(*Nan::Utf8String(info[0])); - const char* refName = strRefName.c_str(); - - git_repository* repo = GetRepository(info); - - if (branch_checkout(repo, refName) == GIT_OK) { - return info.GetReturnValue().Set(Nan::New(true)); - } else if (shouldCreateNewRef) { - git_reference* head; - if (git_repository_head(&head, repo) != GIT_OK) - return info.GetReturnValue().Set(Nan::New(false)); - - const git_oid* sha = git_reference_target(head); - git_commit* commit; - int commitStatus = git_commit_lookup(&commit, repo, sha); - git_reference_free(head); - - if (commitStatus != GIT_OK) - return info.GetReturnValue().Set(Nan::New(false)); - - git_reference* branch; - // N.B.: git_branch_create needs a name like 'xxx', not 'refs/heads/xxx' - const int kShortNameLength = strRefName.length() - 11; - std::string shortRefName(strRefName.c_str() + 11, kShortNameLength); - - int branchCreateStatus = git_branch_create( - &branch, repo, shortRefName.c_str(), commit, 0); - git_commit_free(commit); - - if (branchCreateStatus != GIT_OK) - return info.GetReturnValue().Set(Nan::New(false)); - - git_reference_free(branch); - - if (branch_checkout(repo, refName) == GIT_OK) - return info.GetReturnValue().Set(Nan::New(true)); - } - - return info.GetReturnValue().Set(Nan::New(false)); -} - -NAN_METHOD(Repository::Add) { - Nan::HandleScope scope; - - git_repository* repository = GetRepository(info); - std::string path(*Nan::Utf8String(info[0])); - - git_index* index; - if (git_repository_index(&index, repository) != GIT_OK) { - const git_error* e = giterr_last(); - if (e != NULL) - return Nan::ThrowError(e->message); - else - return Nan::ThrowError("Unknown error opening index"); - } - // Modify the in-memory index. - if (git_index_add_bypath(index, path.c_str()) != GIT_OK) { - git_index_free(index); - const git_error* e = giterr_last(); - if (e != NULL) - return Nan::ThrowError(e->message); - else - return Nan::ThrowError("Unknown error adding path to index"); - } - // Write this change in the index back to disk, so it is persistent - if (git_index_write(index) != GIT_OK) { - git_index_free(index); - const git_error* e = giterr_last(); - if (e != NULL) - return Nan::ThrowError(e->message); - else - return Nan::ThrowError("Unknown error adding path to index"); - } - git_index_free(index); - info.GetReturnValue().Set(Nan::New(true)); -} - -Repository::Repository(Local path, Local search) { - Nan::HandleScope scope; - - int flags = 0; - if (!Nan::To(search).FromJust()) { - flags |= GIT_REPOSITORY_OPEN_NO_SEARCH; - } - - Nan::Utf8String repository_path(path); - int result = git_repository_open_ext(&repository, *repository_path, flags, NULL); - if (result != GIT_OK) { - repository = NULL; - async_repository = NULL; - return; - } - - result = git_repository_open_ext( - &async_repository, - git_repository_path(repository), - GIT_REPOSITORY_OPEN_NO_SEARCH, - NULL - ); - if (result != GIT_OK) { - repository = NULL; - async_repository = NULL; - return; - } -} - -Repository::~Repository() { - if (repository != NULL) { - git_repository_free(repository); - repository = NULL; - } - if (async_repository != NULL) { - git_repository_free(async_repository); - async_repository = NULL; - } -} diff --git a/src/repository.h b/src/repository.h deleted file mode 100644 index cddc4465..00000000 --- a/src/repository.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2013 GitHub Inc. -// -// 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. - -#ifndef SRC_REPOSITORY_H_ -#define SRC_REPOSITORY_H_ - -#include -#include - -#include "git2.h" -#include "nan.h" -using namespace v8; // NOLINT - -class Repository : public Nan::ObjectWrap { - public: - static void Init(Local target); - - private: - static NAN_METHOD(New); - static NAN_METHOD(GetPath); - static NAN_METHOD(GetWorkingDirectory); - static NAN_METHOD(GetSubmodulePaths); - static NAN_METHOD(Exists); - static NAN_METHOD(GetHead); - static NAN_METHOD(GetHeadAsync); - static NAN_METHOD(RefreshIndex); - static NAN_METHOD(IsIgnored); - static NAN_METHOD(IsSubmodule); - static NAN_METHOD(GetConfigValue); - static NAN_METHOD(SetConfigValue); - static NAN_METHOD(GetStatus); - static NAN_METHOD(GetStatusAsync); - static NAN_METHOD(GetStatusForPath); - static NAN_METHOD(CheckoutHead); - static NAN_METHOD(GetReferenceTarget); - static NAN_METHOD(GetDiffStats); - static NAN_METHOD(GetIndexBlob); - static NAN_METHOD(GetHeadBlob); - static NAN_METHOD(CompareCommits); - static NAN_METHOD(CompareCommitsAsync); - static NAN_METHOD(Release); - static NAN_METHOD(GetLineDiffs); - static NAN_METHOD(GetLineDiffDetails); - static NAN_METHOD(GetReferences); - static NAN_METHOD(CheckoutReference); - static NAN_METHOD(Add); - - static int DiffHunkCallback(const git_diff_delta *delta, - const git_diff_hunk *hunk, - void *payload); - static int DiffLineCallback(const git_diff_delta *delta, - const git_diff_hunk *hunk, - const git_diff_line *line, - void *payload); - static int SubmoduleCallback(git_submodule *submodule, const char *name, - void *payload); - - static Local ConvertStringVectorToV8Array( - const std::vector& vector); - - static git_repository* GetRepository(Nan::NAN_METHOD_ARGS_TYPE args); - static git_repository* GetAsyncRepository(Nan::NAN_METHOD_ARGS_TYPE args); - - static int GetBlob(Nan::NAN_METHOD_ARGS_TYPE args, - git_repository* repo, git_blob*& blob); - - static git_diff_options CreateDefaultGitDiffOptions(); - - explicit Repository(Local path, Local search); - ~Repository(); - - git_repository* repository; - git_repository* async_repository; -}; - -#endif // SRC_REPOSITORY_H_ diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 00000000..c6a6452d --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,69 @@ +.highlight { background: #ffffff; } +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #000080 } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/styles.css b/stylesheets/styles.css new file mode 100644 index 00000000..dacf2e18 --- /dev/null +++ b/stylesheets/styles.css @@ -0,0 +1,255 @@ +@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700); + +body { + padding:50px; + font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; + color:#777; + font-weight:300; +} + +h1, h2, h3, h4, h5, h6 { + color:#222; + margin:0 0 20px; +} + +p, ul, ol, table, pre, dl { + margin:0 0 20px; +} + +h1, h2, h3 { + line-height:1.1; +} + +h1 { + font-size:28px; +} + +h2 { + color:#393939; +} + +h3, h4, h5, h6 { + color:#494949; +} + +a { + color:#39c; + font-weight:400; + text-decoration:none; +} + +a small { + font-size:11px; + color:#777; + margin-top:-0.6em; + display:block; +} + +.wrapper { + width:860px; + margin:0 auto; +} + +blockquote { + border-left:1px solid #e5e5e5; + margin:0; + padding:0 0 0 20px; + font-style:italic; +} + +code, pre { + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + color:#333; + font-size:12px; +} + +pre { + padding:8px 15px; + background: #f8f8f8; + border-radius:5px; + border:1px solid #e5e5e5; + overflow-x: auto; +} + +table { + width:100%; + border-collapse:collapse; +} + +th, td { + text-align:left; + padding:5px 10px; + border-bottom:1px solid #e5e5e5; +} + +dt { + color:#444; + font-weight:700; +} + +th { + color:#444; +} + +img { + max-width:100%; +} + +header { + width:270px; + float:left; + position:fixed; +} + +header ul { + list-style:none; + height:40px; + + padding:0; + + background: #eee; + background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); + background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + + border-radius:5px; + border:1px solid #d2d2d2; + box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; + width:270px; +} + +header li { + width:89px; + float:left; + border-right:1px solid #d2d2d2; + height:40px; +} + +header ul a { + line-height:1; + font-size:11px; + color:#999; + display:block; + text-align:center; + padding-top:6px; + height:40px; +} + +strong { + color:#222; + font-weight:700; +} + +header ul li + li { + width:88px; + border-left:1px solid #fff; +} + +header ul li + li + li { + border-right:none; + width:89px; +} + +header ul a strong { + font-size:14px; + display:block; + color:#222; +} + +section { + width:500px; + float:right; + padding-bottom:50px; +} + +small { + font-size:11px; +} + +hr { + border:0; + background:#e5e5e5; + height:1px; + margin:0 0 20px; +} + +footer { + width:270px; + float:left; + position:fixed; + bottom:50px; +} + +@media print, screen and (max-width: 960px) { + + div.wrapper { + width:auto; + margin:0; + } + + header, section, footer { + float:none; + position:static; + width:auto; + } + + header { + padding-right:320px; + } + + section { + border:1px solid #e5e5e5; + border-width:1px 0; + padding:20px 0; + margin:0 0 20px; + } + + header a small { + display:inline; + } + + header ul { + position:absolute; + right:50px; + top:52px; + } +} + +@media print, screen and (max-width: 720px) { + body { + word-wrap:break-word; + } + + header { + padding:0; + } + + header ul, header p.view { + position:static; + } + + pre, code { + word-wrap:normal; + } +} + +@media print, screen and (max-width: 480px) { + body { + padding:15px; + } + + header ul { + display:none; + } +} + +@media print { + body { + padding:0.4in; + font-size:12pt; + color:#444; + } +}