diff --git a/.gitignore b/.gitignore index 3d571d1c7..8fad27538 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /build/ /coverage/ -/dist/ /include/ /lib/enums.js /lib/nodegit.js diff --git a/dist/attr.js b/dist/attr.js new file mode 100644 index 000000000..e280a719e --- /dev/null +++ b/dist/attr.js @@ -0,0 +1,21 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); + +NodeGit.Attr.STATES = {}; +var DEPRECATED_STATES = { + UNSPECIFIED_T: "UNSPECIFIED", + TRUE_T: "TRUE", + FALSE_T: "FALSE", + VALUE_T: "STRING" +}; + +Object.keys(DEPRECATED_STATES).forEach(function (key) { + var newKey = DEPRECATED_STATES[key]; + Object.defineProperty(NodeGit.Attr.STATES, key, { + get: util.deprecate(function () { + return NodeGit.Attr.VALUE[newKey]; + }, "Use NodeGit.Attr.VALUE." + newKey + " instead of NodeGit.Attr.STATES." + key + ".") + }); +}); \ No newline at end of file diff --git a/dist/blame.js b/dist/blame.js new file mode 100644 index 000000000..f40d48167 --- /dev/null +++ b/dist/blame.js @@ -0,0 +1,22 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var Blame = NodeGit.Blame; + +var _file = Blame.file; + +/** + * Retrieve the blame of a file + * + * @async + * @param {Repository} repo that contains the file + * @param {String} path to the file to get the blame of + * @param {BlameOptions} [options] Options for the blame + * @return {Blame} the blame + */ +Blame.file = function (repo, path, options) { + options = normalizeOptions(options, NodeGit.BlameOptions); + + return _file.call(this, repo, path, options); +}; \ No newline at end of file diff --git a/dist/blob.js b/dist/blob.js new file mode 100644 index 000000000..3b1f282a0 --- /dev/null +++ b/dist/blob.js @@ -0,0 +1,71 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); +var Blob = NodeGit.Blob; +var LookupWrapper = NodeGit.Utils.lookupWrapper; +var TreeEntry = NodeGit.TreeEntry; +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var _filteredContent = Blob.filteredContent; +var _filter = Blob.prototype.filter; + +/** +* Retrieves the blob pointed to by the oid +* @async +* @param {Repository} repo The repo that the blob lives in +* @param {String|Oid|Blob} id The blob to lookup +* @return {Blob} +*/ +Blob.lookup = LookupWrapper(Blob); + +/** + * Retrieve the content of the Blob. + * + * @return {Buffer} Contents as a buffer. + */ +Blob.prototype.content = function () { + return this.rawcontent().toBuffer(this.rawsize()); +}; + +/** + * Retrieve the Blob's type. + * + * @return {Number} The filemode of the blob. + */ +Blob.prototype.filemode = function () { + var FileMode = TreeEntry.FILEMODE; + + return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB; +}; + +/** + * Retrieve the Blob's content as String. + * + * @return {String} Contents as a string. + */ +Blob.prototype.toString = function () { + return this.content().toString(); +}; + +/** + * Get a buffer with the filtered content of a blob. + * + * This applies filters as if the blob was being checked out to the + * working directory under the specified filename. This may apply + * CRLF filtering or other types of changes depending on the file + * attributes set for the blob and the content detected in it. + * + * @async + * @param asPath Path used for file attribute lookups, etc. + * @param opts Options to use for filtering the blob + * @return {Promise} + */ +Blob.prototype.filter = function (asPath, opts) { + if (opts) { + opts = normalizeOptions(opts, NodeGit.BlobFilterOptions); + } + return _filter.call(this, asPath, opts); +}; + +Blob.filteredContent = util.deprecate(_filteredContent, "NodeGit.Blob.filteredContent is deprecated" + "use NodeGit.Blob.prototype.filter instead."); \ No newline at end of file diff --git a/dist/branch.js b/dist/branch.js new file mode 100644 index 000000000..4cb2f2b7c --- /dev/null +++ b/dist/branch.js @@ -0,0 +1,20 @@ +"use strict"; + +var NodeGit = require("../"); +var Branch = NodeGit.Branch; + +var _remoteName = Branch.remoteName; + +/** + * Retrieve the Branch's Remote Name as a String. + * + * @async + * @param {Repository} repo The repo to get the remote name from + * @param {String} the refname of the branch + * @return {String} remote name as a string. + */ +Branch.remoteName = function (repo, remoteRef) { + return _remoteName.call(this, repo, remoteRef).then(function (remoteNameBuffer) { + return remoteNameBuffer.toString(); + }); +}; \ No newline at end of file diff --git a/dist/buf.js b/dist/buf.js new file mode 100644 index 000000000..786d9bfa5 --- /dev/null +++ b/dist/buf.js @@ -0,0 +1,16 @@ +"use strict"; + +var _require = require("../"), + Buf = _require.Buf; + +/** + * Sets the content of a GitBuf to a string. + * @param {string} The utf8 value to set in the buffer. + * The string will be null terminated. + */ + + +Buf.prototype.setString = function (content) { + var buf = Buffer.from(content + "\0", "utf8"); + this.set(buf, buf.length); +}; \ No newline at end of file diff --git a/dist/checkout.js b/dist/checkout.js new file mode 100644 index 000000000..06c25652d --- /dev/null +++ b/dist/checkout.js @@ -0,0 +1,53 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Checkout = NodeGit.Checkout; +var _head = Checkout.head; +var _index = Checkout.index; +var _tree = Checkout.tree; + +/** +* Patch head checkout to automatically coerce objects. +* +* @async +* @param {Repository} repo The repo to checkout head +* @param {CheckoutOptions} [options] Options for the checkout +* @return {Void} checkout complete +*/ +Checkout.head = function (url, options) { + options = normalizeOptions(options || {}, NodeGit.CheckoutOptions); + + return _head.call(this, url, options); +}; + +/** +* Patch index checkout to automatically coerce objects. +* +* @async +* @param {Repository} repo The repo to checkout an index +* @param {Index} index The index to checkout +* @param {CheckoutOptions} [options] Options for the checkout +* @return {Void} checkout complete +*/ +Checkout.index = function (repo, index, options) { + options = normalizeOptions(options || {}, NodeGit.CheckoutOptions); + + return _index.call(this, repo, index, options); +}; + +/** +* Patch tree checkout to automatically coerce objects. +* +* @async +* @param {Repository} repo +* @param {String|Tree|Commit|Reference} treeish +* @param {CheckoutOptions} [options] +* @return {Void} checkout complete +*/ +Checkout.tree = function (repo, treeish, options) { + options = normalizeOptions(options || {}, NodeGit.CheckoutOptions); + + return _tree.call(this, repo, treeish, options); +}; \ No newline at end of file diff --git a/dist/cherrypick.js b/dist/cherrypick.js new file mode 100644 index 000000000..ff2c40800 --- /dev/null +++ b/dist/cherrypick.js @@ -0,0 +1,62 @@ +"use strict"; + +var NodeGit = require("../"); +var shallowClone = NodeGit.Utils.shallowClone; +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Cherrypick = NodeGit.Cherrypick; +var _cherrypick = Cherrypick.cherrypick; +var _commit = Cherrypick.commit; + +/** +* Cherrypick a commit and, changing the index and working directory +* +* @async +* @param {Repository} repo The repo to checkout head +* @param {Commit} commit The commit to cherrypick +* @param {CherrypickOptions} [options] Options for the cherrypick +* @return {int} 0 on success, -1 on failure +*/ +Cherrypick.cherrypick = function (repo, commit, options) { + var mergeOpts; + var checkoutOpts; + + if (options) { + options = shallowClone(options); + mergeOpts = options.mergeOpts; + checkoutOpts = options.checkoutOpts; + delete options.mergeOpts; + delete options.checkoutOpts; + } + + options = normalizeOptions(options, NodeGit.CherrypickOptions); + + if (mergeOpts) { + options.mergeOpts = normalizeOptions(mergeOpts, NodeGit.MergeOptions); + } + + if (checkoutOpts) { + options.checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions); + } + + return _cherrypick.call(this, repo, commit, options); +}; + +/** +* Cherrypicks the given commit against "our" commit, producing an index that +* reflects the result of the cherrypick. The index is not backed by a repo. +* +* @async +* @param {Repository} repo The repo to cherrypick commits +* @param {Commit} cherrypick_commit The commit to cherrypick +* @param {Commit} our_commit The commit to revert against +* @param {int} mainline The parent of the revert commit (1 or +* 2) if it's a merge, 0 otherwise +* @param {MergeOptions} [merge_options] Merge options for the cherrypick +* @return {int} 0 on success, -1 on failure +*/ +Cherrypick.commit = function (repo, cherrypick_commit, our_commit, mainline, merge_options) { + merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions); + + return _commit.call(this, repo, cherrypick_commit, our_commit, mainline, merge_options); +}; \ No newline at end of file diff --git a/dist/clone.js b/dist/clone.js new file mode 100644 index 000000000..64838539c --- /dev/null +++ b/dist/clone.js @@ -0,0 +1,35 @@ +"use strict"; + +var NodeGit = require("../"); +var shallowClone = NodeGit.Utils.shallowClone; +var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions; +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Clone = NodeGit.Clone; +var _clone = Clone.clone; + +/** + * Patch repository cloning to automatically coerce objects. + * + * @async + * @param {String} url url of the repository + * @param {String} local_path local path to store repository + * @param {CloneOptions} [options] + * @return {Repository} repo + */ +Clone.clone = function (url, local_path, options) { + var fetchOpts = normalizeFetchOptions(options && options.fetchOpts); + + if (options) { + options = shallowClone(options); + delete options.fetchOpts; + } + + options = normalizeOptions(options, NodeGit.CloneOptions); + + if (options) { + options.fetchOpts = fetchOpts; + } + + return _clone.call(this, url, local_path, options); +}; \ No newline at end of file diff --git a/dist/commit.js b/dist/commit.js new file mode 100644 index 000000000..cb19e3d41 --- /dev/null +++ b/dist/commit.js @@ -0,0 +1,418 @@ +"use strict"; + +var events = require("events"); +var fp = require("lodash/fp"); +var NodeGit = require("../"); +var Commit = NodeGit.Commit; +var LookupWrapper = NodeGit.Utils.lookupWrapper; + +var _amend = Commit.prototype.amend; +var _parent = Commit.prototype.parent; + +/** + * Retrieves the commit pointed to by the oid + * @async + * @param {Repository} repo The repo that the commit lives in + * @param {String|Oid|Commit} id The commit to lookup + * @return {Commit} + */ +Commit.lookup = LookupWrapper(Commit); + +/** + * @async + * @param {Number} n + * @return {Commit} + */ +Commit.prototype.parent = function (n, callback) { + var repo = this.repo; + return _parent.call(this, n).then(function (p) { + p.repo = repo; + + if (typeof callback === "function") { + callback(null, p); + } + + return p; + }, callback); +}; + +/** + * Amend a commit + * @async + * @param {String} update_ref + * @param {Signature} author + * @param {Signature} committer + * @param {String} message_encoding + * @param {String} message + * @param {Tree|Oid} tree + * @param {Oid} callback + */ +Commit.prototype.amend = function (updateRef, author, committer, message_encoding, message, tree, callback) { + var repo = this.repo; + var _this = this; + var treePromise; + + if (tree instanceof NodeGit.Oid) { + treePromise = repo.getTree(tree); + } else { + treePromise = Promise.resolve(tree); + } + + return treePromise.then(function (treeObject) { + return _amend.call(_this, updateRef, author, committer, message_encoding, message, treeObject); + }); +}; + +/** + * Amend a commit with the given signature + * @async + * @param {String} updateRef + * @param {Signature} author + * @param {Signature} committer + * @param {String} messageEncoding + * @param {String} message + * @param {Tree|Oid} tree + * @param {Function} onSignature Callback to be called with string to be signed + * @return {Oid} +*/ +Commit.prototype.amendWithSignature = function (updateRef, author, committer, messageEncoding, message, tree, onSignature) { + var repo = this.repo; + var parentOids = this.parents(); + var _this = this; + var promises = []; + + if (tree instanceof NodeGit.Oid) { + promises.push(repo.getTree(tree)); + } else { + promises.push(Promise.resolve(tree)); + } + + parentOids.forEach(function (parentOid) { + promises.push(repo.getCommit(parentOid)); + }); + + var treeObject = void 0; + var parents = void 0; + var commitContent = void 0; + var commit = void 0; + var skippedSigning = void 0; + var resolvedAuthor = void 0; + var resolvedCommitter = void 0; + var resolvedMessageEncoding = void 0; + var resolvedMessage = void 0; + var resolvedTree = void 0; + + var createCommitPromise = Promise.all(promises).then(function (results) { + treeObject = fp.head(results); + parents = fp.tail(results); + return _this.getTree(); + }).then(function (commitTreeResult) { + var commitTree = commitTreeResult; + + var truthyArgs = fp.omitBy(fp.isNil, { + author: author, + committer: committer, + messageEncoding: messageEncoding, + message: message, + tree: treeObject + }); + + var commitFields = { + author: _this.author(), + committer: _this.committer(), + messageEncoding: _this.messageEncoding(), + message: _this.message(), + tree: commitTree + }; + + var _fp$assign = fp.assign(commitFields, truthyArgs); + + resolvedAuthor = _fp$assign.author; + resolvedCommitter = _fp$assign.committer; + resolvedMessageEncoding = _fp$assign.messageEncoding; + resolvedMessage = _fp$assign.message; + resolvedTree = _fp$assign.tree; + + + return Commit.createBuffer(repo, resolvedAuthor, resolvedCommitter, resolvedMessageEncoding, resolvedMessage, resolvedTree, parents.length, parents); + }).then(function (commitContentResult) { + commitContent = commitContentResult; + if (!commitContent.endsWith("\n")) { + commitContent += "\n"; + } + return onSignature(commitContent); + }).then(function (_ref) { + var code = _ref.code, + field = _ref.field, + signedData = _ref.signedData; + + switch (code) { + case NodeGit.Error.CODE.OK: + return Commit.createWithSignature(repo, commitContent, signedData, field); + case NodeGit.Error.CODE.PASSTHROUGH: + skippedSigning = true; + return Commit.create(repo, updateRef, resolvedAuthor, resolvedCommitter, resolvedMessageEncoding, resolvedMessage, resolvedTree, parents.length, parents); + default: + { + var error = new Error("Commit.amendWithSignature threw with error code " + code); + error.errno = code; + throw error; + } + } + }); + + if (!updateRef) { + return createCommitPromise; + } + + return createCommitPromise.then(function (commitOid) { + if (skippedSigning) { + return commitOid; + } + + return repo.getCommit(commitOid).then(function (commitResult) { + commit = commitResult; + return repo.getReference(updateRef); + }).then(function (ref) { + return ref.setTarget(commitOid, "commit (amend): " + commit.summary()); + }).then(function () { + return commitOid; + }); + }); +}; + +/** + * Retrieve the commit time as a Date object. + * @return {Date} + */ +Commit.prototype.date = function () { + return new Date(this.timeMs()); +}; + +/** + * Generate an array of diff trees showing changes between this commit + * and its parent(s). + * + * @async + * @param {Function} callback + * @return {Array} an array of diffs + */ +Commit.prototype.getDiff = function (callback) { + return this.getDiffWithOptions(null, callback); +}; + +/** + * Generate an array of diff trees showing changes between this commit + * and its parent(s). + * + * @async + * @param {Object} options + * @param {Function} callback + * @return {Array} an array of diffs + */ +Commit.prototype.getDiffWithOptions = function (options, callback) { + var commit = this; + + return commit.getTree().then(function (thisTree) { + return commit.getParents().then(function (parents) { + var diffs; + if (parents.length) { + diffs = parents.map(function (parent) { + return parent.getTree().then(function (parentTree) { + return thisTree.diffWithOptions(parentTree, options); + }); + }); + } else { + diffs = [thisTree.diffWithOptions(null, options)]; + } + + return Promise.all(diffs); + }); + }).then(function (diffs) { + if (typeof callback === "function") { + callback(null, diffs); + } + + return diffs; + }, callback); +}; + +/** + * Retrieve the entry represented by path for this commit. + * Path must be relative to repository root. + * + * @async + * @param {String} path + * @return {TreeEntry} + */ +Commit.prototype.getEntry = function (path, callback) { + return this.getTree().then(function (tree) { + return tree.getEntry(path).then(function (entry) { + if (typeof callback === "function") { + callback(null, entry); + } + + return entry; + }); + }, callback); +}; + +/** + * Retrieve the commit's parents as commit objects. + * + * @async + * @param {number} limit Optional amount of parents to return. + * @param {Function} callback + * @return {Array} array of commits + */ +Commit.prototype.getParents = function (limit, callback) { + var parents = []; + + // Shift arguments. + if (typeof limit === "function") { + callback = limit; + } + + // If no limit was set, default to the maximum parents. + limit = typeof limit === "number" ? limit : this.parentcount(); + limit = Math.min(limit, this.parentcount()); + + for (var i = 0; i < limit; i++) { + var oid = this.parentId(i); + var parent = this.repo.getCommit(oid); + + parents.push(parent); + } + + // Wait for all parents to complete, before returning. + return Promise.all(parents).then(function (parents) { + if (typeof callback === "function") { + callback(null, parents); + } + + return parents; + }, callback); +}; + +/** + * @typedef extractedSignature + * @type {Object} + * @property {String} signature the signature of the commit + * @property {String} signedData the extracted signed data + */ + +/** + * Retrieve the signature and signed data for a commit. + * @param {String} field Optional field to get from the signature, + * defaults to gpgsig + * @return {extractedSignature} + */ +Commit.prototype.getSignature = function (field) { + return Commit.extractSignature(this.repo, this.id(), field); +}; + +/** + * Get the tree associated with this commit. + * + * @async + * @return {Tree} + */ +Commit.prototype.getTree = function (callback) { + return this.repo.getTree(this.treeId(), callback); +}; + +/** + * Walk the history from this commit backwards. + * + * An EventEmitter is returned that will emit a "commit" event for each + * commit in the history, and one "end" event when the walk is completed. + * Don't forget to call `start()` on the returned event. + * + * @fires EventEmitter#commit Commit + * @fires EventEmitter#end Array + * @fires EventEmitter#error Error + * + * @return {EventEmitter} + * @start start() + */ +Commit.prototype.history = function () { + var event = new events.EventEmitter(); + var oid = this.id(); + var revwalk = this.repo.createRevWalk(); + + revwalk.sorting.apply(revwalk, arguments); + + var commits = []; + + event.start = function () { + revwalk.walk(oid, function commitRevWalk(error, commit) { + if (error) { + if (error.errno === NodeGit.Error.CODE.ITEROVER) { + event.emit("end", commits); + return; + } else { + return event.emit("error", error); + } + } + + event.emit("commit", commit); + commits.push(commit); + }); + }; + + return event; +}; + +/** + * Get the specified parent of the commit. + * + * @param {number} the position of the parent, starting from 0 + * @async + * @return {Commit} the parent commit at the specified position + */ +Commit.prototype.parent = function (id) { + var repository = this.repo; + return _parent.call(this, id).then(function (parent) { + parent.repo = repository; + return parent; + }); +}; + +/** + * Retrieve the commit's parent shas. + * + * @return {Array} array of oids + */ +Commit.prototype.parents = function () { + var result = []; + + for (var i = 0; i < this.parentcount(); i++) { + result.push(this.parentId(i)); + } + + return result; +}; + +/** + * Retrieve the SHA. + * @return {String} + */ +Commit.prototype.sha = function () { + return this.id().toString(); +}; + +/** + * Retrieve the commit time as a unix timestamp. + * @return {Number} + */ +Commit.prototype.timeMs = function () { + return this.time() * 1000; +}; + +/** + * The sha of this commit + * @return {String} + */ +Commit.prototype.toString = function () { + return this.sha(); +}; \ No newline at end of file diff --git a/dist/config.js b/dist/config.js new file mode 100644 index 000000000..e63a790ea --- /dev/null +++ b/dist/config.js @@ -0,0 +1,21 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); + +var Config = NodeGit.Config; + +// Backwards compatibility. +Config.prototype.getString = function () { + return this.getStringBuf.apply(this, arguments); +}; + +NodeGit.Enums.CVAR = {}; +var DEPRECATED_CVAR_ENUMS = ["FALSE", "TRUE", "INT32", "STRING"]; +DEPRECATED_CVAR_ENUMS.forEach(function (key) { + Object.defineProperty(NodeGit.Enums.CVAR, key, { + get: util.deprecate(function () { + return Config.MAP[key]; + }, "Use NodeGit.Config.MAP." + key + " instead of NodeGit.Enums.CVAR." + key + ".") + }); +}); \ No newline at end of file diff --git a/dist/convenient_hunks.js b/dist/convenient_hunks.js new file mode 100644 index 000000000..e9a23d78d --- /dev/null +++ b/dist/convenient_hunks.js @@ -0,0 +1,63 @@ +"use strict"; + +var NodeGit = require("../"); + +var ConvenientHunk = NodeGit.ConvenientHunk; + +var header = ConvenientHunk.prototype.header; +/** + * Diff header string that represents the context of this hunk + * of the diff. Something like `@@ -169,14 +167,12 @@ ...` + * @return {String} + */ +ConvenientHunk.prototype.header = header; + +var headerLen = ConvenientHunk.prototype.headerLen; +/** + * The length of the header + * @return {Number} + */ +ConvenientHunk.prototype.headerLen = headerLen; + +var lines = ConvenientHunk.prototype.lines; +/** + * The lines in this hunk + * @async + * @return {Array} + */ +ConvenientHunk.prototype.lines = lines; + +var newLines = ConvenientHunk.prototype.newLines; +/** + * The number of new lines in the hunk + * @return {Number} + */ +ConvenientHunk.prototype.newLines = newLines; + +var newStart = ConvenientHunk.prototype.newStart; +/** + * The starting offset of the first new line in the file + * @return {Number} + */ +ConvenientHunk.prototype.newStart = newStart; + +var oldLines = ConvenientHunk.prototype.oldLines; +/** + * The number of old lines in the hunk + * @return {Number} + */ +ConvenientHunk.prototype.oldLines = oldLines; + +var oldStart = ConvenientHunk.prototype.oldStart; +/** + * The starting offset of the first old line in the file + * @return {Number} + */ +ConvenientHunk.prototype.oldStart = oldStart; + +var size = ConvenientHunk.prototype.size; +/** + * Number of lines in this hunk + * @return {Number} + */ +ConvenientHunk.prototype.size = size; \ No newline at end of file diff --git a/dist/convenient_patch.js b/dist/convenient_patch.js new file mode 100644 index 000000000..c5e635ca9 --- /dev/null +++ b/dist/convenient_patch.js @@ -0,0 +1,133 @@ +"use strict"; + +var NodeGit = require("../"); + +var ConvenientPatch = NodeGit.ConvenientPatch; + +var hunks = ConvenientPatch.prototype.hunks; +/** + * The hunks in this patch + * @async + * @return {Array} a promise that resolves to an array of + * ConvenientHunks + */ +ConvenientPatch.prototype.hunks = hunks; + +var isAdded = ConvenientPatch.prototype.isAdded; +/** + * Is this an added patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isAdded = isAdded; + +var isConflicted = ConvenientPatch.prototype.isConflicted; +/** + * Is this a conflicted patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isConflicted = isConflicted; + +var isCopied = ConvenientPatch.prototype.isCopied; +/** + * Is this a copied patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isCopied = isCopied; + +var isDeleted = ConvenientPatch.prototype.isDeleted; +/** + * Is this a deleted patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isDeleted = isDeleted; + +var isIgnored = ConvenientPatch.prototype.isIgnored; +/** + * Is this an ignored patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isIgnored = isIgnored; + +var isModified = ConvenientPatch.prototype.isModified; +/** + * Is this an modified patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isModified = isModified; + +var isRenamed = ConvenientPatch.prototype.isRenamed; +/** + * Is this a renamed patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isRenamed = isRenamed; + +var isTypeChange = ConvenientPatch.prototype.isTypeChange; +/** + * Is this a type change? + * @return {Boolean} + */ +ConvenientPatch.prototype.isTypeChange = isTypeChange; + +var isUnmodified = ConvenientPatch.prototype.isUnmodified; +/** + * Is this an unmodified patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isUnmodified = isUnmodified; + +var isUnreadable = ConvenientPatch.prototype.isUnreadable; +/** + * Is this an undreadable patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isUnreadable = isUnreadable; + +var isUntracked = ConvenientPatch.prototype.isUntracked; +/** + * Is this an untracked patch? + * @return {Boolean} + */ +ConvenientPatch.prototype.isUntracked = isUntracked; + +/** + * @typedef lineStats + * @type {Object} + * @property {number} total_context # of contexts in the patch + * @property {number} total_additions # of lines added in the patch + * @property {number} total_deletions # of lines deleted in the patch + */ +var lineStats = ConvenientPatch.prototype.lineStats; +/** + * The line statistics of this patch (#contexts, #added, #deleted) + * @return {lineStats} + */ +ConvenientPatch.prototype.lineStats = lineStats; + +var newFile = ConvenientPatch.prototype.newFile; +/** + * New attributes of the file + * @return {DiffFile} + */ +ConvenientPatch.prototype.newFile = newFile; + +var oldFile = ConvenientPatch.prototype.oldFile; +/** + * Old attributes of the file + * @return {DiffFile} + */ +ConvenientPatch.prototype.oldFile = oldFile; + +var size = ConvenientPatch.prototype.size; +/** + * The number of hunks in this patch + * @return {Number} + */ +ConvenientPatch.prototype.size = size; + +var status = ConvenientPatch.prototype.status; +/** + * The status of this patch (unmodified, added, deleted) + * @return {Number} + */ +ConvenientPatch.prototype.status = status; \ No newline at end of file diff --git a/dist/diff.js b/dist/diff.js new file mode 100644 index 000000000..8aec10fe3 --- /dev/null +++ b/dist/diff.js @@ -0,0 +1,94 @@ +"use strict"; + +var NodeGit = require("../"); +var Diff = NodeGit.Diff; +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var Patch = NodeGit.Patch; + +var _blobToBuffer = Diff.blobToBuffer; +var _indexToWorkdir = Diff.indexToWorkdir; +var _treeToIndex = Diff.treeToIndex; +var _treeToTree = Diff.treeToTree; +var _treeToWorkdir = Diff.treeToWorkdir; +var _treeToWorkdirWithIndex = Diff.treeToWorkdirWithIndex; + +var _findSimilar = Diff.prototype.findSimilar; + +/** + * Directly run a diff between a blob and a buffer. + * @async + * @param {Blob} old_blob Blob for old side of diff, or NULL for empty blob + * @param {String} old_as_path Treat old blob as if it had this filename; + * can be NULL + * @param {String} buffer Raw data for new side of diff, or NULL for empty + * @param {String} buffer_as_path Treat buffer as if it had this filename; + * can be NULL + * @param {DiffOptions} opts Options for diff, or NULL for default options + * @param {Function} file_cb Callback for "file"; made once if there is a diff; + * can be NULL + * @param {Function} binary_cb Callback for binary files; can be NULL + * @param {Function} hunk_cb Callback for each hunk in diff; can be NULL + * @param {Function} line_cb Callback for each line in diff; can be NULL + */ +Diff.blobToBuffer = function (old_blob, old_as_path, buffer, buffer_as_path, opts, file_cb, binary_cb, hunk_cb, line_cb) { + var bufferText; + var bufferLength; + if (buffer instanceof Buffer) { + bufferText = buffer.toString("utf8"); + bufferLength = Buffer.byteLength(buffer, "utf8"); + } else { + bufferText = buffer; + bufferLength = !buffer ? 0 : Buffer.byteLength(buffer, "utf8"); + } + + opts = normalizeOptions(opts, NodeGit.DiffOptions); + + return _blobToBuffer.call(this, old_blob, old_as_path, bufferText, bufferLength, buffer_as_path, opts, file_cb, binary_cb, hunk_cb, line_cb, null); +}; + +// Override Diff.indexToWorkdir to normalize opts +Diff.indexToWorkdir = function (repo, index, opts) { + opts = normalizeOptions(opts, NodeGit.DiffOptions); + return _indexToWorkdir(repo, index, opts); +}; + +// Override Diff.treeToIndex to normalize opts +Diff.treeToIndex = function (repo, tree, index, opts) { + opts = normalizeOptions(opts, NodeGit.DiffOptions); + return _treeToIndex(repo, tree, index, opts); +}; + +// Override Diff.treeToTree to normalize opts +Diff.treeToTree = function (repo, from_tree, to_tree, opts) { + opts = normalizeOptions(opts, NodeGit.DiffOptions); + return _treeToTree(repo, from_tree, to_tree, opts); +}; + +// Override Diff.treeToWorkdir to normalize opts +Diff.treeToWorkdir = function (repo, tree, opts) { + opts = normalizeOptions(opts, NodeGit.DiffOptions); + return _treeToWorkdir(repo, tree, opts); +}; + +// Override Diff.treeToWorkdir to normalize opts +Diff.treeToWorkdirWithIndex = function (repo, tree, opts) { + opts = normalizeOptions(opts, NodeGit.DiffOptions); + return _treeToWorkdirWithIndex(repo, tree, opts); +}; + +// Override Diff.findSimilar to normalize opts +Diff.prototype.findSimilar = function (opts) { + opts = normalizeOptions(opts, NodeGit.DiffFindOptions); + return _findSimilar.call(this, opts); +}; + +/** + * Retrieve patches in this difflist + * + * @async + * @return {Array} a promise that resolves to an array of + * ConvenientPatches + */ +Diff.prototype.patches = function () { + return Patch.convenientFromDiff(this); +}; \ No newline at end of file diff --git a/dist/diff_file.js b/dist/diff_file.js new file mode 100644 index 000000000..c88c372b0 --- /dev/null +++ b/dist/diff_file.js @@ -0,0 +1,40 @@ +"use strict"; + +var NodeGit = require("../"); + +var DiffFile = NodeGit.DiffFile; + +var flags = DiffFile.prototype.flags; +/** + * Returns the file's flags + * @return {Number} + */ +DiffFile.prototype.flags = flags; + +var id = DiffFile.prototype.id; +/** + * Returns the file's Oid + * @return {Oid} + */ +DiffFile.prototype.id = id; + +var mode = DiffFile.prototype.mode; +/** + * Returns the file's mode + * @return {Number} + */ +DiffFile.prototype.mode = mode; + +var path = DiffFile.prototype.path; +/** + * Returns the file's path + * @return {String} + */ +DiffFile.prototype.path = path; + +var size = DiffFile.prototype.size; +/** + * Returns the file's size + * @return {Number} + */ +DiffFile.prototype.size = size; \ No newline at end of file diff --git a/dist/diff_line.js b/dist/diff_line.js new file mode 100644 index 000000000..b7060fecc --- /dev/null +++ b/dist/diff_line.js @@ -0,0 +1,32 @@ +"use strict"; + +var NodeGit = require("../"); +var DiffLine = NodeGit.DiffLine; + +var _rawContent = DiffLine.prototype.content; + +/** +* The relevant line +* @return {String} +*/ +DiffLine.prototype.content = function () { + if (!this._cache) { + this._cache = {}; + } + + if (!this._cache.content) { + this._cache.content = new Buffer(this.rawContent()).slice(0, this.contentLen()).toString("utf8"); + } + + return this._cache.content; +}; + +/** +* The non utf8 translated text +* @return {String} +*/ +DiffLine.prototype.rawContent = function () { + return _rawContent.call(this); +}; + +NodeGit.DiffLine = DiffLine; \ No newline at end of file diff --git a/dist/enums.js b/dist/enums.js new file mode 100644 index 000000000..9e13cdc2b --- /dev/null +++ b/dist/enums.js @@ -0,0 +1,689 @@ +"use strict"; + +// This is a generated file, modify: generate/templates/templates/enums.js + +var NodeGit = require("../"); +NodeGit.Enums = {}; + +NodeGit.Apply.FLAGS = { + CHECK: 1 +}; +NodeGit.Apply.LOCATION = { + WORKDIR: 0, + INDEX: 1, + BOTH: 2 +}; +NodeGit.Attr.VALUE = { + UNSPECIFIED: 0, + TRUE: 1, + FALSE: 2, + STRING: 3 +}; +NodeGit.Blame.FLAG = { + NORMAL: 0, + TRACK_COPIES_SAME_FILE: 1, + TRACK_COPIES_SAME_COMMIT_MOVES: 2, + TRACK_COPIES_SAME_COMMIT_COPIES: 4, + TRACK_COPIES_ANY_COMMIT_COPIES: 8, + FIRST_PARENT: 16, + USE_MAILMAP: 32 +}; +NodeGit.Blob.FILTER_FLAG = { + CHECK_FOR_BINARY: 1, + NO_SYSTEM_ATTRIBUTES: 2, + ATTTRIBUTES_FROM_HEAD: 4 +}; +NodeGit.Branch.BRANCH = { + LOCAL: 1, + REMOTE: 2, + ALL: 3 +}; +NodeGit.Cert.TYPE = { + NONE: 0, + X509: 1, + HOSTKEY_LIBSSH2: 2, + STRARRAY: 3 +}; +NodeGit.Cert.SSH = { + MD5: 1, + SHA1: 2, + SHA256: 4 +}; +NodeGit.Checkout.NOTIFY = { + NONE: 0, + CONFLICT: 1, + DIRTY: 2, + UPDATED: 4, + UNTRACKED: 8, + IGNORED: 16, + ALL: 65535 +}; +NodeGit.Checkout.STRATEGY = { + NONE: 0, + SAFE: 1, + FORCE: 2, + RECREATE_MISSING: 4, + ALLOW_CONFLICTS: 16, + REMOVE_UNTRACKED: 32, + REMOVE_IGNORED: 64, + UPDATE_ONLY: 128, + DONT_UPDATE_INDEX: 256, + NO_REFRESH: 512, + SKIP_UNMERGED: 1024, + USE_OURS: 2048, + USE_THEIRS: 4096, + DISABLE_PATHSPEC_MATCH: 8192, + SKIP_LOCKED_DIRECTORIES: 262144, + DONT_OVERWRITE_IGNORED: 524288, + CONFLICT_STYLE_MERGE: 1048576, + CONFLICT_STYLE_DIFF3: 2097152, + DONT_REMOVE_EXISTING: 4194304, + DONT_WRITE_INDEX: 8388608, + UPDATE_SUBMODULES: 65536, + UPDATE_SUBMODULES_IF_CHANGED: 131072 +}; +NodeGit.Clone.LOCAL = { + AUTO: 0, + LOCAL: 1, + NO_LOCAL: 2, + NO_LINKS: 3 +}; +NodeGit.Config.LEVEL = { + PROGRAMDATA: 1, + SYSTEM: 2, + XDG: 3, + GLOBAL: 4, + LOCAL: 5, + APP: 6, + HIGHEST_LEVEL: -1 +}; +NodeGit.Config.MAP = { + FALSE: 0, + TRUE: 1, + INT32: 2, + STRING: 3 +}; +NodeGit.Cred.TYPE = { + USERPASS_PLAINTEXT: 1, + SSH_KEY: 2, + SSH_CUSTOM: 4, + DEFAULT: 8, + SSH_INTERACTIVE: 16, + USERNAME: 32, + SSH_MEMORY: 64 +}; +NodeGit.Diff.DELTA = { + UNMODIFIED: 0, + ADDED: 1, + DELETED: 2, + MODIFIED: 3, + RENAMED: 4, + COPIED: 5, + IGNORED: 6, + UNTRACKED: 7, + TYPECHANGE: 8, + UNREADABLE: 9, + CONFLICTED: 10 +}; +NodeGit.DiffBinary.DIFF_BINARY = { + NONE: 0, + LITERAL: 1, + DELTA: 2 +}; +NodeGit.Diff.FIND = { + BY_CONFIG: 0, + RENAMES: 1, + RENAMES_FROM_REWRITES: 2, + COPIES: 4, + COPIES_FROM_UNMODIFIED: 8, + REWRITES: 16, + BREAK_REWRITES: 32, + AND_BREAK_REWRITES: 48, + FOR_UNTRACKED: 64, + ALL: 255, + IGNORE_LEADING_WHITESPACE: 0, + IGNORE_WHITESPACE: 4096, + DONT_IGNORE_WHITESPACE: 8192, + EXACT_MATCH_ONLY: 16384, + BREAK_REWRITES_FOR_RENAMES_ONLY: 32768, + REMOVE_UNMODIFIED: 65536 +}; +NodeGit.Diff.FLAG = { + BINARY: 1, + NOT_BINARY: 2, + VALID_ID: 4, + EXISTS: 8 +}; +NodeGit.Diff.FORMAT = { + PATCH: 1, + PATCH_HEADER: 2, + RAW: 3, + NAME_ONLY: 4, + NAME_STATUS: 5, + PATCH_ID: 6 +}; +NodeGit.Diff.FORMAT_EMAIL_FLAGS = { + FORMAT_EMAIL_NONE: 0, + FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER: 1 +}; +NodeGit.Diff.LINE = { + CONTEXT: 32, + ADDITION: 43, + DELETION: 45, + CONTEXT_EOFNL: 61, + ADD_EOFNL: 62, + DEL_EOFNL: 60, + FILE_HDR: 70, + HUNK_HDR: 72, + BINARY: 66 +}; +NodeGit.Diff.OPTION = { + NORMAL: 0, + REVERSE: 1, + INCLUDE_IGNORED: 2, + RECURSE_IGNORED_DIRS: 4, + INCLUDE_UNTRACKED: 8, + RECURSE_UNTRACKED_DIRS: 16, + INCLUDE_UNMODIFIED: 32, + INCLUDE_TYPECHANGE: 64, + INCLUDE_TYPECHANGE_TREES: 128, + IGNORE_FILEMODE: 256, + IGNORE_SUBMODULES: 512, + IGNORE_CASE: 1024, + INCLUDE_CASECHANGE: 2048, + DISABLE_PATHSPEC_MATCH: 4096, + SKIP_BINARY_CHECK: 8192, + ENABLE_FAST_UNTRACKED_DIRS: 16384, + UPDATE_INDEX: 32768, + INCLUDE_UNREADABLE: 65536, + INCLUDE_UNREADABLE_AS_UNTRACKED: 131072, + INDENT_HEURISTIC: 262144, + FORCE_TEXT: 1048576, + FORCE_BINARY: 2097152, + IGNORE_WHITESPACE: 4194304, + IGNORE_WHITESPACE_CHANGE: 8388608, + IGNORE_WHITESPACE_EOL: 16777216, + SHOW_UNTRACKED_CONTENT: 33554432, + SHOW_UNMODIFIED: 67108864, + PATIENCE: 268435456, + MINIMAL: 536870912, + SHOW_BINARY: 1073741824 +}; +NodeGit.Diff.STATS_FORMAT = { + STATS_NONE: 0, + STATS_FULL: 1, + STATS_SHORT: 2, + STATS_NUMBER: 4, + STATS_INCLUDE_SUMMARY: 8 +}; +NodeGit.Enums.DIRECTION = { + FETCH: 0, + PUSH: 1 +}; +NodeGit.Error.ERROR = { + NONE: 0, + NOMEMORY: 1, + OS: 2, + INVALID: 3, + REFERENCE: 4, + ZLIB: 5, + REPOSITORY: 6, + CONFIG: 7, + REGEX: 8, + ODB: 9, + INDEX: 10, + OBJECT: 11, + NET: 12, + TAG: 13, + TREE: 14, + INDEXER: 15, + SSL: 16, + SUBMODULE: 17, + THREAD: 18, + STASH: 19, + CHECKOUT: 20, + FETCHHEAD: 21, + MERGE: 22, + SSH: 23, + FILTER: 24, + REVERT: 25, + CALLBACK: 26, + CHERRYPICK: 27, + DESCRIBE: 28, + REBASE: 29, + FILESYSTEM: 30, + PATCH: 31, + WORKTREE: 32, + SHA1: 33 +}; +NodeGit.Error.CODE = { + OK: 0, + ERROR: -1, + ENOTFOUND: -3, + EEXISTS: -4, + EAMBIGUOUS: -5, + EBUFS: -6, + EUSER: -7, + EBAREREPO: -8, + EUNBORNBRANCH: -9, + EUNMERGED: -10, + ENONFASTFORWARD: -11, + EINVALIDSPEC: -12, + ECONFLICT: -13, + ELOCKED: -14, + EMODIFIED: -15, + EAUTH: -16, + ECERTIFICATE: -17, + EAPPLIED: -18, + EPEEL: -19, + EEOF: -20, + EINVALID: -21, + EUNCOMMITTED: -22, + EDIRECTORY: -23, + EMERGECONFLICT: -24, + PASSTHROUGH: -30, + ITEROVER: -31, + RETRY: -32, + EMISMATCH: -33, + EINDEXDIRTY: -34, + EAPPLYFAIL: -35 +}; +NodeGit.Enums.FEATURE = { + THREADS: 1, + HTTPS: 2, + SSH: 4, + NSEC: 8 +}; +NodeGit.Fetch.PRUNE = { + GIT_FETCH_PRUNE_UNSPECIFIED: 0, + GIT_FETCH_PRUNE: 1, + GIT_FETCH_NO_PRUNE: 2 +}; +NodeGit.TreeEntry.FILEMODE = { + UNREADABLE: 0, + TREE: 16384, + BLOB: 33188, + EXECUTABLE: 33261, + LINK: 40960, + COMMIT: 57344 +}; +NodeGit.Filter.FLAG = { + DEFAULT: 0, + ALLOW_UNSAFE: 1, + NO_SYSTEM_ATTRIBUTES: 2, + ATTRIBUTES_FROM_HEAD: 4 +}; +NodeGit.Filter.MODE = { + TO_WORKTREE: 0, + SMUDGE: 0, + TO_ODB: 1, + CLEAN: 1 +}; +NodeGit.Hashsig.OPTION = { + NORMAL: 0, + IGNORE_WHITESPACE: 1, + SMART_WHITESPACE: 2, + ALLOW_SMALL_FILES: 4 +}; +NodeGit.Index.ADD_OPTION = { + ADD_DEFAULT: 0, + ADD_FORCE: 1, + ADD_DISABLE_PATHSPEC_MATCH: 2, + ADD_CHECK_PATHSPEC: 4 +}; +NodeGit.Index.CAPABILITY = { + IGNORE_CASE: 1, + NO_FILEMODE: 2, + NO_SYMLINKS: 4, + FROM_OWNER: -1 +}; +NodeGit.Index.ENTRY_EXTENDED_FLAG = { + ENTRY_INTENT_TO_ADD: 8192, + ENTRY_SKIP_WORKTREE: 16384, + S: 24576, + ENTRY_UPTODATE: 4 +}; +NodeGit.Index.ENTRY_FLAG = { + ENTRY_EXTENDED: 16384, + ENTRY_VALID: 32768 +}; +NodeGit.Index.STAGE = { + ANY: -1, + NORMAL: 0, + ANCESTOR: 1, + OURS: 2, + THEIRS: 3 +}; +NodeGit.Libgit2.OPT = { + GET_MWINDOW_SIZE: 0, + SET_MWINDOW_SIZE: 1, + GET_MWINDOW_MAPPED_LIMIT: 2, + SET_MWINDOW_MAPPED_LIMIT: 3, + GET_SEARCH_PATH: 4, + SET_SEARCH_PATH: 5, + SET_CACHE_OBJECT_LIMIT: 6, + SET_CACHE_MAX_SIZE: 7, + ENABLE_CACHING: 8, + GET_CACHED_MEMORY: 9, + GET_TEMPLATE_PATH: 10, + SET_TEMPLATE_PATH: 11, + SET_SSL_CERT_LOCATIONS: 12, + SET_USER_AGENT: 13, + ENABLE_STRICT_OBJECT_CREATION: 14, + ENABLE_STRICT_SYMBOLIC_REF_CREATION: 15, + SET_SSL_CIPHERS: 16, + GET_USER_AGENT: 17, + ENABLE_OFS_DELTA: 18, + ENABLE_FSYNC_GITDIR: 19, + GET_WINDOWS_SHAREMODE: 20, + SET_WINDOWS_SHAREMODE: 21, + ENABLE_STRICT_HASH_VERIFICATION: 22, + SET_ALLOCATOR: 23, + ENABLE_UNSAVED_INDEX_SAFETY: 24, + GET_PACK_MAX_OBJECTS: 25, + SET_PACK_MAX_OBJECTS: 26, + DISABLE_PACK_KEEP_FILE_CHECKS: 27 +}; +NodeGit.Merge.ANALYSIS = { + NONE: 0, + NORMAL: 1, + UP_TO_DATE: 2, + FASTFORWARD: 4, + UNBORN: 8 +}; +NodeGit.Merge.FILE_FAVOR = { + NORMAL: 0, + OURS: 1, + THEIRS: 2, + UNION: 3 +}; +NodeGit.Merge.FILE_FLAG = { + FILE_DEFAULT: 0, + FILE_STYLE_MERGE: 1, + FILE_STYLE_DIFF3: 2, + FILE_SIMPLIFY_ALNUM: 4, + FILE_IGNORE_WHITESPACE: 8, + FILE_IGNORE_WHITESPACE_CHANGE: 16, + FILE_IGNORE_WHITESPACE_EOL: 32, + FILE_DIFF_PATIENCE: 64, + FILE_DIFF_MINIMAL: 128 +}; +NodeGit.Merge.FLAG = { + FIND_RENAMES: 1, + FAIL_ON_CONFLICT: 2, + SKIP_REUC: 4, + NO_RECURSIVE: 8 +}; +NodeGit.Merge.PREFERENCE = { + NONE: 0, + NO_FASTFORWARD: 1, + FASTFORWARD_ONLY: 2 +}; +NodeGit.Object.TYPE = { + ANY: -2, + INVALID: -1, + COMMIT: 1, + TREE: 2, + BLOB: 3, + TAG: 4, + OFS_DELTA: 6, + REF_DELTA: 7 +}; +NodeGit.Odb.STREAM = { + RDONLY: 2, + WRONLY: 4, + RW: 6 +}; +NodeGit.Packbuilder.STAGE = { + ADDING_OBJECTS: 0, + DELTAFICATION: 1 +}; +NodeGit.Path.FS = { + GENERIC: 0, + NTFS: 1, + HFS: 2 +}; +NodeGit.Path.GITFILE = { + GITIGNORE: 0, + GITMODULES: 1, + GITATTRIBUTES: 1 +}; +NodeGit.Pathspec.FLAG = { + DEFAULT: 0, + IGNORE_CASE: 1, + USE_CASE: 2, + NO_GLOB: 4, + NO_MATCH_ERROR: 8, + FIND_FAILURES: 16, + FAILURES_ONLY: 32 +}; +NodeGit.Proxy.PROXY = { + NONE: 0, + AUTO: 1, + SPECIFIED: 2 +}; +NodeGit.RebaseOperation.REBASE_OPERATION = { + PICK: 0, + REWORD: 1, + EDIT: 2, + SQUASH: 3, + FIXUP: 4, + EXEC: 5 +}; +NodeGit.Reference.TYPE = { + INVALID: 0, + DIRECT: 1, + SYMBOLIC: 2, + ALL: 3 +}; +NodeGit.Reference.FORMAT = { + NORMAL: 0, + ALLOW_ONELEVEL: 1, + REFSPEC_PATTERN: 2, + REFSPEC_SHORTHAND: 4 +}; +NodeGit.Remote.AUTOTAG_OPTION = { + DOWNLOAD_TAGS_UNSPECIFIED: 0, + DOWNLOAD_TAGS_AUTO: 1, + DOWNLOAD_TAGS_NONE: 2, + DOWNLOAD_TAGS_ALL: 3 +}; +NodeGit.Remote.COMPLETION = { + DOWNLOAD: 0, + INDEXING: 1, + ERROR: 2 +}; +NodeGit.Remote.CREATE_FLAGS = { + CREATE_SKIP_INSTEADOF: 1, + CREATE_SKIP_DEFAULT_FETCHSPEC: 2 +}; +NodeGit.Repository.INIT_FLAG = { + BARE: 1, + NO_REINIT: 2, + NO_DOTGIT_DIR: 4, + MKDIR: 8, + MKPATH: 16, + EXTERNAL_TEMPLATE: 32, + RELATIVE_GITLINK: 64 +}; +NodeGit.Repository.INIT_MODE = { + INIT_SHARED_UMASK: 0, + INIT_SHARED_GROUP: 1533, + INIT_SHARED_ALL: 1535 +}; +NodeGit.Repository.ITEM = { + GITDIR: 0, + WORKDIR: 1, + COMMONDIR: 2, + INDEX: 3, + OBJECTS: 4, + REFS: 5, + PACKED_REFS: 6, + REMOTES: 7, + CONFIG: 8, + INFO: 9, + HOOKS: 10, + LOGS: 11, + MODULES: 12, + WORKTREES: 13, + _LAST: 14 +}; +NodeGit.Repository.OPEN_FLAG = { + OPEN_NO_SEARCH: 1, + OPEN_CROSS_FS: 2, + OPEN_BARE: 4, + OPEN_NO_DOTGIT: 8, + OPEN_FROM_ENV: 16 +}; +NodeGit.Repository.STATE = { + NONE: 0, + MERGE: 1, + REVERT: 2, + REVERT_SEQUENCE: 3, + CHERRYPICK: 4, + CHERRYPICK_SEQUENCE: 5, + BISECT: 6, + REBASE: 7, + REBASE_INTERACTIVE: 8, + REBASE_MERGE: 9, + APPLY_MAILBOX: 10, + APPLY_MAILBOX_OR_REBASE: 11 +}; +NodeGit.Reset.TYPE = { + SOFT: 1, + MIXED: 2, + HARD: 3 +}; +NodeGit.Revparse.MODE = { + SINGLE: 1, + RANGE: 2, + MERGE_BASE: 4 +}; +NodeGit.Enums.SMART_SERVICE = { + SERVICE_UPLOADPACK_LS: 1, + SERVICE_UPLOADPACK: 2, + SERVICE_RECEIVEPACK_LS: 3, + SERVICE_RECEIVEPACK: 4 +}; +NodeGit.Revwalk.SORT = { + NONE: 0, + TOPOLOGICAL: 1, + TIME: 2, + REVERSE: 4 +}; +NodeGit.Stash.APPLY_FLAGS = { + APPLY_DEFAULT: 0, + APPLY_REINSTATE_INDEX: 1 +}; +NodeGit.Stash.APPLY_PROGRESS = { + NONE: 0, + LOADING_STASH: 1, + ANALYZE_INDEX: 2, + ANALYZE_MODIFIED: 3, + ANALYZE_UNTRACKED: 4, + CHECKOUT_UNTRACKED: 5, + CHECKOUT_MODIFIED: 6, + DONE: 7 +}; +NodeGit.Stash.FLAGS = { + DEFAULT: 0, + KEEP_INDEX: 1, + INCLUDE_UNTRACKED: 2, + INCLUDE_IGNORED: 4 +}; +NodeGit.Status.STATUS = { + CURRENT: 0, + INDEX_NEW: 1, + INDEX_MODIFIED: 2, + INDEX_DELETED: 4, + INDEX_RENAMED: 8, + INDEX_TYPECHANGE: 16, + WT_NEW: 128, + WT_MODIFIED: 256, + WT_DELETED: 512, + WT_TYPECHANGE: 1024, + WT_RENAMED: 2048, + WT_UNREADABLE: 4096, + IGNORED: 16384, + CONFLICTED: 32768 +}; +NodeGit.Status.OPT = { + INCLUDE_UNTRACKED: 1, + INCLUDE_IGNORED: 2, + INCLUDE_UNMODIFIED: 4, + EXCLUDE_SUBMODULES: 8, + RECURSE_UNTRACKED_DIRS: 16, + DISABLE_PATHSPEC_MATCH: 32, + RECURSE_IGNORED_DIRS: 64, + RENAMES_HEAD_TO_INDEX: 128, + RENAMES_INDEX_TO_WORKDIR: 256, + SORT_CASE_SENSITIVELY: 512, + SORT_CASE_INSENSITIVELY: 1024, + RENAMES_FROM_REWRITES: 2048, + NO_REFRESH: 4096, + UPDATE_INDEX: 8192, + INCLUDE_UNREADABLE: 16384, + INCLUDE_UNREADABLE_AS_UNTRACKED: 32768 +}; +NodeGit.Status.SHOW = { + INDEX_AND_WORKDIR: 0, + INDEX_ONLY: 1, + WORKDIR_ONLY: 2 +}; +NodeGit.Submodule.IGNORE = { + UNSPECIFIED: -1, + NONE: 1, + UNTRACKED: 2, + DIRTY: 3, + ALL: 4 +}; +NodeGit.Submodule.RECURSE = { + NO: 0, + YES: 1, + ONDEMAND: 2 +}; +NodeGit.Submodule.STATUS = { + IN_HEAD: 1, + IN_INDEX: 2, + IN_CONFIG: 4, + IN_WD: 8, + INDEX_ADDED: 16, + INDEX_DELETED: 32, + INDEX_MODIFIED: 64, + WD_UNINITIALIZED: 128, + WD_ADDED: 256, + WD_DELETED: 512, + WD_MODIFIED: 1024, + WD_INDEX_MODIFIED: 2048, + WD_WD_MODIFIED: 4096, + WD_UNTRACKED: 8192 +}; +NodeGit.Submodule.UPDATE = { + CHECKOUT: 1, + REBASE: 2, + MERGE: 3, + NONE: 4, + DEFAULT: 0 +}; +NodeGit.Trace.LEVEL = { + NONE: 0, + FATAL: 1, + ERROR: 2, + WARN: 3, + INFO: 4, + DEBUG: 5, + TRACE: 6 +}; +NodeGit.Tree.UPDATE = { + UPSERT: 0, + REMOVE: 1 +}; +NodeGit.Tree.WALK_MODE = { + WALK_PRE: 0, + WALK_POST: 1 +}; +NodeGit.Worktree.PRUNE = { + GIT_WORKTREE_PRUNE_VALID: 1, + GIT_WORKTREE_PRUNE_LOCKED: 2, + GIT_WORKTREE_PRUNE_WORKING_TREE: 4 +}; \ No newline at end of file diff --git a/dist/error.js b/dist/error.js new file mode 100644 index 000000000..87673139a --- /dev/null +++ b/dist/error.js @@ -0,0 +1,17 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); + +// Deprecated ----------------------------------------------------------------- + +// In 0.28.0 git_error was majorly refactored to have better naming in libgit2 +// We will continue to support the old enum entries but with a deprecation +// warning as they will go away soon. +Object.keys(NodeGit.Error.CODE).forEach(function (key) { + Object.defineProperty(NodeGit.Error.CODE, "GITERR_" + key, { + get: util.deprecate(function () { + return NodeGit.Error.CODE[key]; + }, "Use NodeGit.Error.CODE." + key + " instead of " + ("NodeGit.Error.CODE.GETERR_" + key + ".")) + }); +}); \ No newline at end of file diff --git a/dist/filter_registry.js b/dist/filter_registry.js new file mode 100644 index 000000000..ebf1baddc --- /dev/null +++ b/dist/filter_registry.js @@ -0,0 +1,40 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var FilterRegistry = NodeGit.FilterRegistry; + +var _register = FilterRegistry.register; +var _unregister = FilterRegistry.unregister; + +// register should add filter by name to dict and return +// Override FilterRegistry.register to normalize Filter +FilterRegistry.register = function (name, filter, priority, callback) { + // setting default value of attributes + if (filter.attributes === undefined) { + filter.attributes = ""; + } + + filter = normalizeOptions(filter, NodeGit.Filter); + + if (!filter.check || !filter.apply) { + return callback(new Error("ERROR: please provide check and apply callbacks for filter")); + } + + return _register(name, filter, priority).then(function (result) { + if (typeof callback === "function") { + callback(null, result); + } + return result; + }, callback); +}; + +FilterRegistry.unregister = function (name, callback) { + return _unregister(name).then(function (result) { + if (typeof callback === "function") { + callback(null, result); + } + return result; + }, callback); +}; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 000000000..5df0c1223 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,96 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); + +var Index = NodeGit.Index; + +var _addAll = Index.prototype.addAll; +var _removeAll = Index.prototype.removeAll; +var _updateAll = Index.prototype.updateAll; + +Index.prototype.addAll = function (pathspec, flags, matchedCallback) { + return _addAll.call(this, pathspec || "*", flags, matchedCallback, null); +}; + +/** + * Return an array of the entries in this index. + * @return {Array} an array of IndexEntrys + */ +Index.prototype.entries = function () { + var size = this.entryCount(); + var result = []; + + for (var i = 0; i < size; i++) { + result.push(this.getByIndex(i)); + } + + return result; +}; + +Index.prototype.removeAll = function (pathspec, matchedCallback) { + return _removeAll.call(this, pathspec || "*", matchedCallback, null); +}; + +Index.prototype.updateAll = function (pathspec, matchedCallback) { + return _updateAll.call(this, pathspec || "*", matchedCallback, null); +}; + +// Deprecated ----------------------------------------------------------------- + +NodeGit.Index.CAP = {}; +Object.keys(NodeGit.Index.CAPABILITY).forEach(function (key) { + Object.defineProperty(NodeGit.Index.CAP, key, { + get: util.deprecate(function () { + return NodeGit.Index.CAPABILITY[key]; + }, "Use NodeGit.Index.CAPABILITY." + key + " instead of " + ("NodeGit.Index.CAP." + key + ".")) + }); +}); + +NodeGit.Enums.INDXENTRY_FLAG = {}; +Object.defineProperty(NodeGit.Enums.INDXENTRY_FLAG, "IDXENTRY_EXTENDED", { + get: util.deprecate(function () { + return NodeGit.Index.ENTRY_FLAG.ENTRY_EXTENDED; + }, "Use NodeGit.Index.ENTRY_FLAG.ENTRY_EXTENDED instead of " + "NodeGit.Enums.INDXENTRY_FLAG.IDXENTRY_EXTENDED.") +}); +Object.defineProperty(NodeGit.Enums.INDXENTRY_FLAG, "IDXENTRY_VALID", { + get: util.deprecate(function () { + return NodeGit.Index.ENTRY_FLAG.ENTRY_VALID; + }, "Use NodeGit.Index.ENTRY_FLAG.ENTRY_VALID instead of " + "NodeGit.Enums.INDXENTRY_FLAG.IDXENTRY_VALID.") +}); + +NodeGit.Enums.IDXENTRY_EXTENDED_FLAG = {}; +var EXTENDED_FLAGS_MAP = { + IDXENTRY_INTENT_TO_ADD: "ENTRY_INTENT_TO_ADD", + IDXENTRY_SKIP_WORKTREE: "ENTRY_SKIP_WORKTREE", + S: "S", + IDXENTRY_UPTODATE: "ENTRY_UPTODATE" +}; +Object.keys(EXTENDED_FLAGS_MAP).forEach(function (key) { + var newKey = EXTENDED_FLAGS_MAP[key]; + Object.defineProperty(NodeGit.Enums.IDXENTRY_EXTENDED_FLAG, key, { + get: util.deprecate(function () { + return NodeGit.Index.ENTRY_EXTENDED_FLAG[newKey]; + }, "Use NodeGit.Index.ENTRY_EXTENDED_FLAG." + newKey + " instead of " + ("NodeGit.Enums.IDXENTRY_EXTENDED_FLAG." + key + ".")) + }); +}); + +var DEPRECATED_EXTENDED_FLAGS = { + IDXENTRY_EXTENDED2: 32768, + IDXENTRY_UPDATE: 1, + IDXENTRY_REMOVE: 2, + IDXENTRY_ADDED: 8, + IDXENTRY_HASHED: 16, + IDXENTRY_UNHASHED: 32, + IDXENTRY_WT_REMOVE: 64, + IDXENTRY_CONFLICTED: 128, + IDXENTRY_UNPACKED: 256, + IDXENTRY_NEW_SKIP_WORKTREE: 512 +}; +Object.keys(DEPRECATED_EXTENDED_FLAGS).forEach(function (key) { + Object.defineProperty(NodeGit.Enums.IDXENTRY_EXTENDED_FLAG, key, { + get: util.deprecate(function () { + return DEPRECATED_EXTENDED_FLAGS[key]; + }, "LibGit2 has removed this flag for public usage.") + }); +}); \ No newline at end of file diff --git a/dist/libgit2.js b/dist/libgit2.js new file mode 100644 index 000000000..c157385ba --- /dev/null +++ b/dist/libgit2.js @@ -0,0 +1,8 @@ +"use strict"; + +var NodeGit = require("../"); + +var Libgit2 = NodeGit.Libgit2; + +Libgit2.OPT.SET_WINDOWS_LONGPATHS = 28; +Libgit2.OPT.GET_WINDOWS_LONGPATHS = 29; \ No newline at end of file diff --git a/dist/merge.js b/dist/merge.js new file mode 100644 index 000000000..36cb69c3e --- /dev/null +++ b/dist/merge.js @@ -0,0 +1,45 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Merge = NodeGit.Merge; +var _commits = Merge.commits; +var _merge = Merge.merge; + +/** + * Merge 2 commits together and create an new index that can + * be used to create a merge commit. + * + * @param {Repository} repo Repository that contains the given commits + * @param {Commit} ourCommit The commit that reflects the destination tree + * @param {Commit} theirCommit The commit to merge into ourCommit + * @param {MergeOptions} [options] The merge tree options (null for default) + */ +Merge.commits = function (repo, ourCommit, theirCommit, options) { + options = normalizeOptions(options, NodeGit.MergeOptions); + + return Promise.all([repo.getCommit(ourCommit), repo.getCommit(theirCommit)]).then(function (commits) { + return _commits.call(this, repo, commits[0], commits[1], options); + }); +}; + +/** + * Merge a commit into HEAD and writes the results to the working directory. + * + * @param {Repository} repo Repository that contains the given commits + * @param {AnnotatedCommit} theirHead The annotated commit to merge into HEAD + * @param {MergeOptions} [mergeOpts] The merge tree options (null for default) + * @param {CheckoutOptions} [checkoutOpts] The checkout options + * (null for default) + */ +Merge.merge = function (repo, theirHead, mergeOpts, checkoutOpts) { + mergeOpts = normalizeOptions(mergeOpts || {}, NodeGit.MergeOptions); + checkoutOpts = normalizeOptions(checkoutOpts || {}, NodeGit.CheckoutOptions); + + // Even though git_merge takes an array of annotated_commits, it expects + // exactly one to have been passed in or it will throw an error... ¯\_(ツ)_/¯ + var theirHeads = [theirHead]; + + return _merge.call(this, repo, theirHeads, theirHeads.length, mergeOpts, checkoutOpts); +}; \ No newline at end of file diff --git a/dist/nodegit.js b/dist/nodegit.js new file mode 100644 index 000000000..234f696df --- /dev/null +++ b/dist/nodegit.js @@ -0,0 +1,1308 @@ +"use strict"; + +// This is a generated file, modify: generate/templates/templates/nodegit.js + +var _ = require("lodash"); +var promisify = require("promisify-node"); +var rawApi; + +// Attempt to load the production release first, if it fails fall back to the +// debug release. +try { + rawApi = require("../build/Release/nodegit.node"); +} catch (ex) { + /* istanbul ignore next */ + if (ex.code !== "MODULE_NOT_FOUND") { + throw ex; + } + + rawApi = require("../build/Debug/nodegit.node"); +} + +// For disccussion on why `cloneDeep` is required, see: +// https://github.com/facebook/jest/issues/3552 +// https://github.com/facebook/jest/issues/3550 +// https://github.com/nodejs/node/issues/5016 +rawApi = _.cloneDeep(rawApi); + +// Native methods do not return an identifiable function, so we +// have to override them here +/* jshint ignore:start */ +var _AnnotatedCommit = rawApi.AnnotatedCommit; + +var _AnnotatedCommit_fromFetchhead = _AnnotatedCommit.fromFetchhead; +_AnnotatedCommit.fromFetchhead = promisify(_AnnotatedCommit_fromFetchhead); + +var _AnnotatedCommit_fromRef = _AnnotatedCommit.fromRef; +_AnnotatedCommit.fromRef = promisify(_AnnotatedCommit_fromRef); + +var _AnnotatedCommit_fromRevspec = _AnnotatedCommit.fromRevspec; +_AnnotatedCommit.fromRevspec = promisify(_AnnotatedCommit_fromRevspec); + +var _AnnotatedCommit_lookup = _AnnotatedCommit.lookup; +_AnnotatedCommit.lookup = promisify(_AnnotatedCommit_lookup); + +var _Apply = rawApi.Apply; + +var _Apply_toTree = _Apply.toTree; +_Apply.toTree = promisify(_Apply_toTree); + +var _Attr = rawApi.Attr; + +var _Attr_get = _Attr.get; +_Attr.get = promisify(_Attr_get); + +var _Attr_getMany = _Attr.getMany; +_Attr.getMany = promisify(_Attr_getMany); + +var _Blame = rawApi.Blame; + +var _Blame_buffer = _Blame.prototype.buffer; +_Blame.prototype.buffer = promisify(_Blame_buffer); + +var _Blame_file = _Blame.file; +_Blame.file = promisify(_Blame_file); + +var _Blob = rawApi.Blob; + +var _Blob_createFromBuffer = _Blob.createFromBuffer; +_Blob.createFromBuffer = promisify(_Blob_createFromBuffer); + +var _Blob_createFromDisk = _Blob.createFromDisk; +_Blob.createFromDisk = promisify(_Blob_createFromDisk); + +var _Blob_createFromWorkdir = _Blob.createFromWorkdir; +_Blob.createFromWorkdir = promisify(_Blob_createFromWorkdir); + +var _Blob_dup = _Blob.prototype.dup; +_Blob.prototype.dup = promisify(_Blob_dup); + +var _Blob_filter = _Blob.prototype.filter; +_Blob.prototype.filter = promisify(_Blob_filter); + +var _Blob_filteredContent = _Blob.filteredContent; +_Blob.filteredContent = promisify(_Blob_filteredContent); + +var _Blob_lookup = _Blob.lookup; +_Blob.lookup = promisify(_Blob_lookup); + +var _Blob_lookupPrefix = _Blob.lookupPrefix; +_Blob.lookupPrefix = promisify(_Blob_lookupPrefix); + +var _Branch = rawApi.Branch; + +var _Branch_create = _Branch.create; +_Branch.create = promisify(_Branch_create); + +var _Branch_createFromAnnotated = _Branch.createFromAnnotated; +_Branch.createFromAnnotated = promisify(_Branch_createFromAnnotated); + +var _Branch_lookup = _Branch.lookup; +_Branch.lookup = promisify(_Branch_lookup); + +var _Branch_move = _Branch.move; +_Branch.move = promisify(_Branch_move); + +var _Branch_name = _Branch.name; +_Branch.name = promisify(_Branch_name); + +var _Branch_remoteName = _Branch.remoteName; +_Branch.remoteName = promisify(_Branch_remoteName); + +var _Branch_setUpstream = _Branch.setUpstream; +_Branch.setUpstream = promisify(_Branch_setUpstream); + +var _Branch_upstream = _Branch.upstream; +_Branch.upstream = promisify(_Branch_upstream); + +var _Branch_upstreamName = _Branch.upstreamName; +_Branch.upstreamName = promisify(_Branch_upstreamName); + +var _Buf = rawApi.Buf; +var _Checkout = rawApi.Checkout; + +var _Checkout_head = _Checkout.head; +_Checkout.head = promisify(_Checkout_head); + +var _Checkout_index = _Checkout.index; +_Checkout.index = promisify(_Checkout_index); + +var _Checkout_tree = _Checkout.tree; +_Checkout.tree = promisify(_Checkout_tree); + +var _Cherrypick = rawApi.Cherrypick; + +var _Cherrypick_cherrypick = _Cherrypick.cherrypick; +_Cherrypick.cherrypick = promisify(_Cherrypick_cherrypick); + +var _Cherrypick_commit = _Cherrypick.commit; +_Cherrypick.commit = promisify(_Cherrypick_commit); + +var _Clone = rawApi.Clone; + +var _Clone_clone = _Clone.clone; +_Clone.clone = promisify(_Clone_clone); + +var _Commit = rawApi.Commit; + +var _Commit_amend = _Commit.prototype.amend; +_Commit.prototype.amend = promisify(_Commit_amend); + +var _Commit_authorWithMailmap = _Commit.prototype.authorWithMailmap; +_Commit.prototype.authorWithMailmap = promisify(_Commit_authorWithMailmap); + +var _Commit_committerWithMailmap = _Commit.prototype.committerWithMailmap; +_Commit.prototype.committerWithMailmap = promisify(_Commit_committerWithMailmap); + +var _Commit_create = _Commit.create; +_Commit.create = promisify(_Commit_create); + +var _Commit_createBuffer = _Commit.createBuffer; +_Commit.createBuffer = promisify(_Commit_createBuffer); + +var _Commit_createWithSignature = _Commit.createWithSignature; +_Commit.createWithSignature = promisify(_Commit_createWithSignature); + +var _Commit_dup = _Commit.prototype.dup; +_Commit.prototype.dup = promisify(_Commit_dup); + +var _Commit_extractSignature = _Commit.extractSignature; +_Commit.extractSignature = promisify(_Commit_extractSignature); + +var _Commit_headerField = _Commit.prototype.headerField; +_Commit.prototype.headerField = promisify(_Commit_headerField); + +var _Commit_lookup = _Commit.lookup; +_Commit.lookup = promisify(_Commit_lookup); + +var _Commit_lookupPrefix = _Commit.lookupPrefix; +_Commit.lookupPrefix = promisify(_Commit_lookupPrefix); + +var _Commit_nthGenAncestor = _Commit.prototype.nthGenAncestor; +_Commit.prototype.nthGenAncestor = promisify(_Commit_nthGenAncestor); + +var _Commit_parent = _Commit.prototype.parent; +_Commit.prototype.parent = promisify(_Commit_parent); + +var _Config = rawApi.Config; + +var _Config_findGlobal = _Config.findGlobal; +_Config.findGlobal = promisify(_Config_findGlobal); + +var _Config_findProgramdata = _Config.findProgramdata; +_Config.findProgramdata = promisify(_Config_findProgramdata); + +var _Config_findSystem = _Config.findSystem; +_Config.findSystem = promisify(_Config_findSystem); + +var _Config_findXdg = _Config.findXdg; +_Config.findXdg = promisify(_Config_findXdg); + +var _Config_getBool = _Config.prototype.getBool; +_Config.prototype.getBool = promisify(_Config_getBool); + +var _Config_getEntry = _Config.prototype.getEntry; +_Config.prototype.getEntry = promisify(_Config_getEntry); + +var _Config_getInt32 = _Config.prototype.getInt32; +_Config.prototype.getInt32 = promisify(_Config_getInt32); + +var _Config_getInt64 = _Config.prototype.getInt64; +_Config.prototype.getInt64 = promisify(_Config_getInt64); + +var _Config_getPath = _Config.prototype.getPath; +_Config.prototype.getPath = promisify(_Config_getPath); + +var _Config_getStringBuf = _Config.prototype.getStringBuf; +_Config.prototype.getStringBuf = promisify(_Config_getStringBuf); + +var _Config_lock = _Config.prototype.lock; +_Config.prototype.lock = promisify(_Config_lock); + +var _Config_openDefault = _Config.openDefault; +_Config.openDefault = promisify(_Config_openDefault); + +var _Config_openOndisk = _Config.openOndisk; +_Config.openOndisk = promisify(_Config_openOndisk); + +var _Config_setBool = _Config.prototype.setBool; +_Config.prototype.setBool = promisify(_Config_setBool); + +var _Config_setInt32 = _Config.prototype.setInt32; +_Config.prototype.setInt32 = promisify(_Config_setInt32); + +var _Config_setInt64 = _Config.prototype.setInt64; +_Config.prototype.setInt64 = promisify(_Config_setInt64); + +var _Config_setMultivar = _Config.prototype.setMultivar; +_Config.prototype.setMultivar = promisify(_Config_setMultivar); + +var _Config_setString = _Config.prototype.setString; +_Config.prototype.setString = promisify(_Config_setString); + +var _Config_snapshot = _Config.prototype.snapshot; +_Config.prototype.snapshot = promisify(_Config_snapshot); + +var _ConfigIterator = rawApi.ConfigIterator; + +var _ConfigIterator_create = _ConfigIterator.create; +_ConfigIterator.create = promisify(_ConfigIterator_create); + +var _ConfigIterator_createGlob = _ConfigIterator.createGlob; +_ConfigIterator.createGlob = promisify(_ConfigIterator_createGlob); + +var _ConfigIterator_createMultivar = _ConfigIterator.createMultivar; +_ConfigIterator.createMultivar = promisify(_ConfigIterator_createMultivar); + +var _Cred = rawApi.Cred; + +var _Cred_sshKeyMemoryNew = _Cred.sshKeyMemoryNew; +_Cred.sshKeyMemoryNew = promisify(_Cred_sshKeyMemoryNew); + +var _Cred_usernameNew = _Cred.usernameNew; +_Cred.usernameNew = promisify(_Cred_usernameNew); + +var _Diff = rawApi.Diff; + +var _Diff_blobToBuffer = _Diff.blobToBuffer; +_Diff.blobToBuffer = promisify(_Diff_blobToBuffer); + +var _Diff_findSimilar = _Diff.prototype.findSimilar; +_Diff.prototype.findSimilar = promisify(_Diff_findSimilar); + +var _Diff_fromBuffer = _Diff.fromBuffer; +_Diff.fromBuffer = promisify(_Diff_fromBuffer); + +var _Diff_getStats = _Diff.prototype.getStats; +_Diff.prototype.getStats = promisify(_Diff_getStats); + +var _Diff_indexToIndex = _Diff.indexToIndex; +_Diff.indexToIndex = promisify(_Diff_indexToIndex); + +var _Diff_indexToWorkdir = _Diff.indexToWorkdir; +_Diff.indexToWorkdir = promisify(_Diff_indexToWorkdir); + +var _Diff_merge = _Diff.prototype.merge; +_Diff.prototype.merge = promisify(_Diff_merge); + +var _Diff_patchid = _Diff.prototype.patchid; +_Diff.prototype.patchid = promisify(_Diff_patchid); + +var _Diff_toBuf = _Diff.prototype.toBuf; +_Diff.prototype.toBuf = promisify(_Diff_toBuf); + +var _Diff_treeToIndex = _Diff.treeToIndex; +_Diff.treeToIndex = promisify(_Diff_treeToIndex); + +var _Diff_treeToTree = _Diff.treeToTree; +_Diff.treeToTree = promisify(_Diff_treeToTree); + +var _Diff_treeToWorkdir = _Diff.treeToWorkdir; +_Diff.treeToWorkdir = promisify(_Diff_treeToWorkdir); + +var _Diff_treeToWorkdirWithIndex = _Diff.treeToWorkdirWithIndex; +_Diff.treeToWorkdirWithIndex = promisify(_Diff_treeToWorkdirWithIndex); + +var _DiffStats = rawApi.DiffStats; + +var _DiffStats_toBuf = _DiffStats.prototype.toBuf; +_DiffStats.prototype.toBuf = promisify(_DiffStats_toBuf); + +var _Error = rawApi.Error; +var _Filter = rawApi.Filter; + +var _Filter_applyToBlob = _Filter.prototype.applyToBlob; +_Filter.prototype.applyToBlob = promisify(_Filter_applyToBlob); + +var _Filter_applyToData = _Filter.prototype.applyToData; +_Filter.prototype.applyToData = promisify(_Filter_applyToData); + +var _Filter_applyToFile = _Filter.prototype.applyToFile; +_Filter.prototype.applyToFile = promisify(_Filter_applyToFile); + +var _Filter_load = _Filter.load; +_Filter.load = promisify(_Filter_load); + +var _FilterList = rawApi.FilterList; + +var _FilterList_applyToBlob = _FilterList.prototype.applyToBlob; +_FilterList.prototype.applyToBlob = promisify(_FilterList_applyToBlob); + +var _FilterList_applyToData = _FilterList.prototype.applyToData; +_FilterList.prototype.applyToData = promisify(_FilterList_applyToData); + +var _FilterList_applyToFile = _FilterList.prototype.applyToFile; +_FilterList.prototype.applyToFile = promisify(_FilterList_applyToFile); + +var _FilterList_load = _FilterList.load; +_FilterList.load = promisify(_FilterList_load); + +var _FilterSource = rawApi.FilterSource; + +var _FilterSource_repo = _FilterSource.prototype.repo; +_FilterSource.prototype.repo = promisify(_FilterSource_repo); + +var _Graph = rawApi.Graph; + +var _Graph_aheadBehind = _Graph.aheadBehind; +_Graph.aheadBehind = promisify(_Graph_aheadBehind); + +var _Graph_descendantOf = _Graph.descendantOf; +_Graph.descendantOf = promisify(_Graph_descendantOf); + +var _Hashsig = rawApi.Hashsig; + +var _Hashsig_create = _Hashsig.create; +_Hashsig.create = promisify(_Hashsig_create); + +var _Hashsig_createFromFile = _Hashsig.createFromFile; +_Hashsig.createFromFile = promisify(_Hashsig_createFromFile); + +var _Ignore = rawApi.Ignore; + +var _Ignore_pathIsIgnored = _Ignore.pathIsIgnored; +_Ignore.pathIsIgnored = promisify(_Ignore_pathIsIgnored); + +var _Index = rawApi.Index; + +var _Index_add = _Index.prototype.add; +_Index.prototype.add = promisify(_Index_add); + +var _Index_addAll = _Index.prototype.addAll; +_Index.prototype.addAll = promisify(_Index_addAll); + +var _Index_addByPath = _Index.prototype.addByPath; +_Index.prototype.addByPath = promisify(_Index_addByPath); + +var _Index_clear = _Index.prototype.clear; +_Index.prototype.clear = promisify(_Index_clear); + +var _Index_conflictAdd = _Index.prototype.conflictAdd; +_Index.prototype.conflictAdd = promisify(_Index_conflictAdd); + +var _Index_conflictCleanup = _Index.prototype.conflictCleanup; +_Index.prototype.conflictCleanup = promisify(_Index_conflictCleanup); + +var _Index_conflictGet = _Index.prototype.conflictGet; +_Index.prototype.conflictGet = promisify(_Index_conflictGet); + +var _Index_conflictRemove = _Index.prototype.conflictRemove; +_Index.prototype.conflictRemove = promisify(_Index_conflictRemove); + +var _Index_find = _Index.prototype.find; +_Index.prototype.find = promisify(_Index_find); + +var _Index_findPrefix = _Index.prototype.findPrefix; +_Index.prototype.findPrefix = promisify(_Index_findPrefix); + +var _Index_open = _Index.open; +_Index.open = promisify(_Index_open); + +var _Index_read = _Index.prototype.read; +_Index.prototype.read = promisify(_Index_read); + +var _Index_readTree = _Index.prototype.readTree; +_Index.prototype.readTree = promisify(_Index_readTree); + +var _Index_remove = _Index.prototype.remove; +_Index.prototype.remove = promisify(_Index_remove); + +var _Index_removeAll = _Index.prototype.removeAll; +_Index.prototype.removeAll = promisify(_Index_removeAll); + +var _Index_removeByPath = _Index.prototype.removeByPath; +_Index.prototype.removeByPath = promisify(_Index_removeByPath); + +var _Index_removeDirectory = _Index.prototype.removeDirectory; +_Index.prototype.removeDirectory = promisify(_Index_removeDirectory); + +var _Index_updateAll = _Index.prototype.updateAll; +_Index.prototype.updateAll = promisify(_Index_updateAll); + +var _Index_write = _Index.prototype.write; +_Index.prototype.write = promisify(_Index_write); + +var _Index_writeTree = _Index.prototype.writeTree; +_Index.prototype.writeTree = promisify(_Index_writeTree); + +var _Index_writeTreeTo = _Index.prototype.writeTreeTo; +_Index.prototype.writeTreeTo = promisify(_Index_writeTreeTo); + +var _IndexConflictIterator = rawApi.IndexConflictIterator; + +var _IndexConflictIterator_create = _IndexConflictIterator.create; +_IndexConflictIterator.create = promisify(_IndexConflictIterator_create); + +var _IndexIterator = rawApi.IndexIterator; + +var _IndexIterator_create = _IndexIterator.create; +_IndexIterator.create = promisify(_IndexIterator_create); + +var _IndexNameEntry = rawApi.IndexNameEntry; + +var _IndexNameEntry_add = _IndexNameEntry.add; +_IndexNameEntry.add = promisify(_IndexNameEntry_add); + +var _IndexNameEntry_clear = _IndexNameEntry.clear; +_IndexNameEntry.clear = promisify(_IndexNameEntry_clear); + +var _IndexReucEntry = rawApi.IndexReucEntry; + +var _IndexReucEntry_add = _IndexReucEntry.add; +_IndexReucEntry.add = promisify(_IndexReucEntry_add); + +var _IndexReucEntry_clear = _IndexReucEntry.clear; +_IndexReucEntry.clear = promisify(_IndexReucEntry_clear); + +var _IndexReucEntry_find = _IndexReucEntry.find; +_IndexReucEntry.find = promisify(_IndexReucEntry_find); + +var _IndexReucEntry_remove = _IndexReucEntry.remove; +_IndexReucEntry.remove = promisify(_IndexReucEntry_remove); + +var _Libgit2 = rawApi.Libgit2; +var _Mailmap = rawApi.Mailmap; + +var _Mailmap_addEntry = _Mailmap.prototype.addEntry; +_Mailmap.prototype.addEntry = promisify(_Mailmap_addEntry); + +var _Mailmap_fromBuffer = _Mailmap.fromBuffer; +_Mailmap.fromBuffer = promisify(_Mailmap_fromBuffer); + +var _Mailmap_fromRepository = _Mailmap.fromRepository; +_Mailmap.fromRepository = promisify(_Mailmap_fromRepository); + +var _Mailmap_create = _Mailmap.create; +_Mailmap.create = promisify(_Mailmap_create); + +var _Mailmap_resolve = _Mailmap.prototype.resolve; +_Mailmap.prototype.resolve = promisify(_Mailmap_resolve); + +var _Mailmap_resolveSignature = _Mailmap.prototype.resolveSignature; +_Mailmap.prototype.resolveSignature = promisify(_Mailmap_resolveSignature); + +var _Merge = rawApi.Merge; + +var _Merge_merge = _Merge.merge; +_Merge.merge = promisify(_Merge_merge); + +var _Merge_analysis = _Merge.analysis; +_Merge.analysis = promisify(_Merge_analysis); + +var _Merge_analysisForRef = _Merge.analysisForRef; +_Merge.analysisForRef = promisify(_Merge_analysisForRef); + +var _Merge_base = _Merge.base; +_Merge.base = promisify(_Merge_base); + +var _Merge_bases = _Merge.bases; +_Merge.bases = promisify(_Merge_bases); + +var _Merge_commits = _Merge.commits; +_Merge.commits = promisify(_Merge_commits); + +var _Merge_trees = _Merge.trees; +_Merge.trees = promisify(_Merge_trees); + +var _Note = rawApi.Note; + +var _Note_commitIteratorNew = _Note.commitIteratorNew; +_Note.commitIteratorNew = promisify(_Note_commitIteratorNew); + +var _Note_commitRead = _Note.commitRead; +_Note.commitRead = promisify(_Note_commitRead); + +var _Note_commitRemove = _Note.commitRemove; +_Note.commitRemove = promisify(_Note_commitRemove); + +var _Note_create = _Note.create; +_Note.create = promisify(_Note_create); + +var _Note_defaultRef = _Note.defaultRef; +_Note.defaultRef = promisify(_Note_defaultRef); + +var _Note_foreach = _Note.foreach; +_Note.foreach = promisify(_Note_foreach); + +var _Note_read = _Note.read; +_Note.read = promisify(_Note_read); + +var _Note_remove = _Note.remove; +_Note.remove = promisify(_Note_remove); + +var _Object = rawApi.Object; + +var _Object_dup = _Object.prototype.dup; +_Object.prototype.dup = promisify(_Object_dup); + +var _Object_lookup = _Object.lookup; +_Object.lookup = promisify(_Object_lookup); + +var _Object_lookupByPath = _Object.prototype.lookupByPath; +_Object.prototype.lookupByPath = promisify(_Object_lookupByPath); + +var _Object_lookupPrefix = _Object.lookupPrefix; +_Object.lookupPrefix = promisify(_Object_lookupPrefix); + +var _Object_peel = _Object.prototype.peel; +_Object.prototype.peel = promisify(_Object_peel); + +var _Object_shortId = _Object.prototype.shortId; +_Object.prototype.shortId = promisify(_Object_shortId); + +var _Odb = rawApi.Odb; + +var _Odb_addDiskAlternate = _Odb.prototype.addDiskAlternate; +_Odb.prototype.addDiskAlternate = promisify(_Odb_addDiskAlternate); + +var _Odb_existsPrefix = _Odb.prototype.existsPrefix; +_Odb.prototype.existsPrefix = promisify(_Odb_existsPrefix); + +var _Odb_hashfile = _Odb.hashfile; +_Odb.hashfile = promisify(_Odb_hashfile); + +var _Odb_open = _Odb.open; +_Odb.open = promisify(_Odb_open); + +var _Odb_read = _Odb.prototype.read; +_Odb.prototype.read = promisify(_Odb_read); + +var _Odb_readPrefix = _Odb.prototype.readPrefix; +_Odb.prototype.readPrefix = promisify(_Odb_readPrefix); + +var _Odb_write = _Odb.prototype.write; +_Odb.prototype.write = promisify(_Odb_write); + +var _OdbObject = rawApi.OdbObject; +var _Oid = rawApi.Oid; +var _OidShorten = rawApi.OidShorten; +var _Packbuilder = rawApi.Packbuilder; + +var _Packbuilder_insert = _Packbuilder.prototype.insert; +_Packbuilder.prototype.insert = promisify(_Packbuilder_insert); + +var _Packbuilder_insertCommit = _Packbuilder.prototype.insertCommit; +_Packbuilder.prototype.insertCommit = promisify(_Packbuilder_insertCommit); + +var _Packbuilder_insertRecur = _Packbuilder.prototype.insertRecur; +_Packbuilder.prototype.insertRecur = promisify(_Packbuilder_insertRecur); + +var _Packbuilder_insertWalk = _Packbuilder.prototype.insertWalk; +_Packbuilder.prototype.insertWalk = promisify(_Packbuilder_insertWalk); + +var _Patch = rawApi.Patch; + +var _Patch_fromBlobs = _Patch.fromBlobs; +_Patch.fromBlobs = promisify(_Patch_fromBlobs); + +var _Patch_fromDiff = _Patch.fromDiff; +_Patch.fromDiff = promisify(_Patch_fromDiff); + +var _Patch_getHunk = _Patch.prototype.getHunk; +_Patch.prototype.getHunk = promisify(_Patch_getHunk); + +var _Patch_getLineInHunk = _Patch.prototype.getLineInHunk; +_Patch.prototype.getLineInHunk = promisify(_Patch_getLineInHunk); + +var _Patch_convenientFromDiff = _Patch.convenientFromDiff; +_Patch.convenientFromDiff = promisify(_Patch_convenientFromDiff); + +var _Path = rawApi.Path; +var _Pathspec = rawApi.Pathspec; + +var _Pathspec_matchDiff = _Pathspec.prototype.matchDiff; +_Pathspec.prototype.matchDiff = promisify(_Pathspec_matchDiff); + +var _Pathspec_matchIndex = _Pathspec.prototype.matchIndex; +_Pathspec.prototype.matchIndex = promisify(_Pathspec_matchIndex); + +var _Pathspec_matchTree = _Pathspec.prototype.matchTree; +_Pathspec.prototype.matchTree = promisify(_Pathspec_matchTree); + +var _Pathspec_matchWorkdir = _Pathspec.prototype.matchWorkdir; +_Pathspec.prototype.matchWorkdir = promisify(_Pathspec_matchWorkdir); + +var _PathspecMatchList = rawApi.PathspecMatchList; +var _Rebase = rawApi.Rebase; + +var _Rebase_abort = _Rebase.prototype.abort; +_Rebase.prototype.abort = promisify(_Rebase_abort); + +var _Rebase_commit = _Rebase.prototype.commit; +_Rebase.prototype.commit = promisify(_Rebase_commit); + +var _Rebase_init = _Rebase.init; +_Rebase.init = promisify(_Rebase_init); + +var _Rebase_next = _Rebase.prototype.next; +_Rebase.prototype.next = promisify(_Rebase_next); + +var _Rebase_open = _Rebase.open; +_Rebase.open = promisify(_Rebase_open); + +var _Refdb = rawApi.Refdb; + +var _Refdb_open = _Refdb.open; +_Refdb.open = promisify(_Refdb_open); + +var _Reference = rawApi.Reference; + +var _Reference_create = _Reference.create; +_Reference.create = promisify(_Reference_create); + +var _Reference_createMatching = _Reference.createMatching; +_Reference.createMatching = promisify(_Reference_createMatching); + +var _Reference_dup = _Reference.prototype.dup; +_Reference.prototype.dup = promisify(_Reference_dup); + +var _Reference_dwim = _Reference.dwim; +_Reference.dwim = promisify(_Reference_dwim); + +var _Reference_list = _Reference.list; +_Reference.list = promisify(_Reference_list); + +var _Reference_lookup = _Reference.lookup; +_Reference.lookup = promisify(_Reference_lookup); + +var _Reference_nameToId = _Reference.nameToId; +_Reference.nameToId = promisify(_Reference_nameToId); + +var _Reference_peel = _Reference.prototype.peel; +_Reference.prototype.peel = promisify(_Reference_peel); + +var _Reference_rename = _Reference.prototype.rename; +_Reference.prototype.rename = promisify(_Reference_rename); + +var _Reference_resolve = _Reference.prototype.resolve; +_Reference.prototype.resolve = promisify(_Reference_resolve); + +var _Reference_setTarget = _Reference.prototype.setTarget; +_Reference.prototype.setTarget = promisify(_Reference_setTarget); + +var _Reference_symbolicCreate = _Reference.symbolicCreate; +_Reference.symbolicCreate = promisify(_Reference_symbolicCreate); + +var _Reference_symbolicCreateMatching = _Reference.symbolicCreateMatching; +_Reference.symbolicCreateMatching = promisify(_Reference_symbolicCreateMatching); + +var _Reference_symbolicSetTarget = _Reference.prototype.symbolicSetTarget; +_Reference.prototype.symbolicSetTarget = promisify(_Reference_symbolicSetTarget); + +var _Reflog = rawApi.Reflog; + +var _Reflog_read = _Reflog.read; +_Reflog.read = promisify(_Reflog_read); + +var _Reflog_write = _Reflog.prototype.write; +_Reflog.prototype.write = promisify(_Reflog_write); + +var _ReflogEntry = rawApi.ReflogEntry; +var _Refspec = rawApi.Refspec; + +var _Refspec_parse = _Refspec.parse; +_Refspec.parse = promisify(_Refspec_parse); + +var _Remote = rawApi.Remote; + +var _Remote_connect = _Remote.prototype.connect; +_Remote.prototype.connect = promisify(_Remote_connect); + +var _Remote_create = _Remote.create; +_Remote.create = promisify(_Remote_create); + +var _Remote_createAnonymous = _Remote.createAnonymous; +_Remote.createAnonymous = promisify(_Remote_createAnonymous); + +var _Remote_createDetached = _Remote.createDetached; +_Remote.createDetached = promisify(_Remote_createDetached); + +var _Remote_createWithFetchspec = _Remote.createWithFetchspec; +_Remote.createWithFetchspec = promisify(_Remote_createWithFetchspec); + +var _Remote_createWithOpts = _Remote.createWithOpts; +_Remote.createWithOpts = promisify(_Remote_createWithOpts); + +var _Remote_defaultBranch = _Remote.prototype.defaultBranch; +_Remote.prototype.defaultBranch = promisify(_Remote_defaultBranch); + +var _Remote_delete = _Remote.delete; +_Remote.delete = promisify(_Remote_delete); + +var _Remote_disconnect = _Remote.prototype.disconnect; +_Remote.prototype.disconnect = promisify(_Remote_disconnect); + +var _Remote_download = _Remote.prototype.download; +_Remote.prototype.download = promisify(_Remote_download); + +var _Remote_dup = _Remote.prototype.dup; +_Remote.prototype.dup = promisify(_Remote_dup); + +var _Remote_fetch = _Remote.prototype.fetch; +_Remote.prototype.fetch = promisify(_Remote_fetch); + +var _Remote_getFetchRefspecs = _Remote.prototype.getFetchRefspecs; +_Remote.prototype.getFetchRefspecs = promisify(_Remote_getFetchRefspecs); + +var _Remote_getPushRefspecs = _Remote.prototype.getPushRefspecs; +_Remote.prototype.getPushRefspecs = promisify(_Remote_getPushRefspecs); + +var _Remote_list = _Remote.list; +_Remote.list = promisify(_Remote_list); + +var _Remote_lookup = _Remote.lookup; +_Remote.lookup = promisify(_Remote_lookup); + +var _Remote_push = _Remote.prototype.push; +_Remote.prototype.push = promisify(_Remote_push); + +var _Remote_updateTips = _Remote.prototype.updateTips; +_Remote.prototype.updateTips = promisify(_Remote_updateTips); + +var _Remote_upload = _Remote.prototype.upload; +_Remote.prototype.upload = promisify(_Remote_upload); + +var _Remote_referenceList = _Remote.prototype.referenceList; +_Remote.prototype.referenceList = promisify(_Remote_referenceList); + +var _Repository = rawApi.Repository; + +var _Repository_config = _Repository.prototype.config; +_Repository.prototype.config = promisify(_Repository_config); + +var _Repository_discover = _Repository.discover; +_Repository.discover = promisify(_Repository_discover); + +var _Repository_fetchheadForeach = _Repository.prototype.fetchheadForeach; +_Repository.prototype.fetchheadForeach = promisify(_Repository_fetchheadForeach); + +var _Repository_head = _Repository.prototype.head; +_Repository.prototype.head = promisify(_Repository_head); + +var _Repository_headForWorktree = _Repository.prototype.headForWorktree; +_Repository.prototype.headForWorktree = promisify(_Repository_headForWorktree); + +var _Repository_index = _Repository.prototype.index; +_Repository.prototype.index = promisify(_Repository_index); + +var _Repository_init = _Repository.init; +_Repository.init = promisify(_Repository_init); + +var _Repository_initExt = _Repository.initExt; +_Repository.initExt = promisify(_Repository_initExt); + +var _Repository_itemPath = _Repository.prototype.itemPath; +_Repository.prototype.itemPath = promisify(_Repository_itemPath); + +var _Repository_mergeheadForeach = _Repository.prototype.mergeheadForeach; +_Repository.prototype.mergeheadForeach = promisify(_Repository_mergeheadForeach); + +var _Repository_odb = _Repository.prototype.odb; +_Repository.prototype.odb = promisify(_Repository_odb); + +var _Repository_open = _Repository.open; +_Repository.open = promisify(_Repository_open); + +var _Repository_openBare = _Repository.openBare; +_Repository.openBare = promisify(_Repository_openBare); + +var _Repository_openExt = _Repository.openExt; +_Repository.openExt = promisify(_Repository_openExt); + +var _Repository_openFromWorktree = _Repository.openFromWorktree; +_Repository.openFromWorktree = promisify(_Repository_openFromWorktree); + +var _Repository_refdb = _Repository.prototype.refdb; +_Repository.prototype.refdb = promisify(_Repository_refdb); + +var _Repository_setHead = _Repository.prototype.setHead; +_Repository.prototype.setHead = promisify(_Repository_setHead); + +var _Repository_wrapOdb = _Repository.wrapOdb; +_Repository.wrapOdb = promisify(_Repository_wrapOdb); + +var _Repository_cleanup = _Repository.prototype.cleanup; +_Repository.prototype.cleanup = promisify(_Repository_cleanup); + +var _Repository_getReferences = _Repository.prototype.getReferences; +_Repository.prototype.getReferences = promisify(_Repository_getReferences); + +var _Repository_getSubmodules = _Repository.prototype.getSubmodules; +_Repository.prototype.getSubmodules = promisify(_Repository_getSubmodules); + +var _Repository_getRemotes = _Repository.prototype.getRemotes; +_Repository.prototype.getRemotes = promisify(_Repository_getRemotes); + +var _Repository_refreshReferences = _Repository.prototype.refreshReferences; +_Repository.prototype.refreshReferences = promisify(_Repository_refreshReferences); + +var _Reset = rawApi.Reset; + +var _Reset_reset = _Reset.reset; +_Reset.reset = promisify(_Reset_reset); + +var _Reset_default = _Reset.default; +_Reset.default = promisify(_Reset_default); + +var _Reset_fromAnnotated = _Reset.fromAnnotated; +_Reset.fromAnnotated = promisify(_Reset_fromAnnotated); + +var _Revert = rawApi.Revert; + +var _Revert_revert = _Revert.revert; +_Revert.revert = promisify(_Revert_revert); + +var _Revert_commit = _Revert.commit; +_Revert.commit = promisify(_Revert_commit); + +var _Revparse = rawApi.Revparse; + +var _Revparse_single = _Revparse.single; +_Revparse.single = promisify(_Revparse_single); + +var _Revwalk = rawApi.Revwalk; + +var _Revwalk_next = _Revwalk.prototype.next; +_Revwalk.prototype.next = promisify(_Revwalk_next); + +var _Revwalk_commitWalk = _Revwalk.prototype.commitWalk; +_Revwalk.prototype.commitWalk = promisify(_Revwalk_commitWalk); + +var _Revwalk_fastWalk = _Revwalk.prototype.fastWalk; +_Revwalk.prototype.fastWalk = promisify(_Revwalk_fastWalk); + +var _Revwalk_fileHistoryWalk = _Revwalk.prototype.fileHistoryWalk; +_Revwalk.prototype.fileHistoryWalk = promisify(_Revwalk_fileHistoryWalk); + +var _Signature = rawApi.Signature; + +var _Signature_default = _Signature.default; +_Signature.default = promisify(_Signature_default); + +var _Signature_fromBuffer = _Signature.fromBuffer; +_Signature.fromBuffer = promisify(_Signature_fromBuffer); + +var _Stash = rawApi.Stash; + +var _Stash_apply = _Stash.apply; +_Stash.apply = promisify(_Stash_apply); + +var _Stash_drop = _Stash.drop; +_Stash.drop = promisify(_Stash_drop); + +var _Stash_foreach = _Stash.foreach; +_Stash.foreach = promisify(_Stash_foreach); + +var _Stash_pop = _Stash.pop; +_Stash.pop = promisify(_Stash_pop); + +var _Stash_save = _Stash.save; +_Stash.save = promisify(_Stash_save); + +var _Status = rawApi.Status; + +var _Status_file = _Status.file; +_Status.file = promisify(_Status_file); + +var _Status_foreach = _Status.foreach; +_Status.foreach = promisify(_Status_foreach); + +var _Status_foreachExt = _Status.foreachExt; +_Status.foreachExt = promisify(_Status_foreachExt); + +var _StatusList = rawApi.StatusList; + +var _StatusList_create = _StatusList.create; +_StatusList.create = promisify(_StatusList_create); + +var _Strarray = rawApi.Strarray; +var _Submodule = rawApi.Submodule; + +var _Submodule_addFinalize = _Submodule.prototype.addFinalize; +_Submodule.prototype.addFinalize = promisify(_Submodule_addFinalize); + +var _Submodule_addSetup = _Submodule.addSetup; +_Submodule.addSetup = promisify(_Submodule_addSetup); + +var _Submodule_addToIndex = _Submodule.prototype.addToIndex; +_Submodule.prototype.addToIndex = promisify(_Submodule_addToIndex); + +var _Submodule_clone = _Submodule.prototype.clone; +_Submodule.prototype.clone = promisify(_Submodule_clone); + +var _Submodule_foreach = _Submodule.foreach; +_Submodule.foreach = promisify(_Submodule_foreach); + +var _Submodule_init = _Submodule.prototype.init; +_Submodule.prototype.init = promisify(_Submodule_init); + +var _Submodule_location = _Submodule.prototype.location; +_Submodule.prototype.location = promisify(_Submodule_location); + +var _Submodule_lookup = _Submodule.lookup; +_Submodule.lookup = promisify(_Submodule_lookup); + +var _Submodule_open = _Submodule.prototype.open; +_Submodule.prototype.open = promisify(_Submodule_open); + +var _Submodule_repoInit = _Submodule.prototype.repoInit; +_Submodule.prototype.repoInit = promisify(_Submodule_repoInit); + +var _Submodule_resolveUrl = _Submodule.resolveUrl; +_Submodule.resolveUrl = promisify(_Submodule_resolveUrl); + +var _Submodule_setIgnore = _Submodule.setIgnore; +_Submodule.setIgnore = promisify(_Submodule_setIgnore); + +var _Submodule_setUpdate = _Submodule.setUpdate; +_Submodule.setUpdate = promisify(_Submodule_setUpdate); + +var _Submodule_setUrl = _Submodule.setUrl; +_Submodule.setUrl = promisify(_Submodule_setUrl); + +var _Submodule_status = _Submodule.status; +_Submodule.status = promisify(_Submodule_status); + +var _Submodule_sync = _Submodule.prototype.sync; +_Submodule.prototype.sync = promisify(_Submodule_sync); + +var _Submodule_update = _Submodule.prototype.update; +_Submodule.prototype.update = promisify(_Submodule_update); + +var _Tag = rawApi.Tag; + +var _Tag_annotationCreate = _Tag.annotationCreate; +_Tag.annotationCreate = promisify(_Tag_annotationCreate); + +var _Tag_create = _Tag.create; +_Tag.create = promisify(_Tag_create); + +var _Tag_createFromBuffer = _Tag.createFromBuffer; +_Tag.createFromBuffer = promisify(_Tag_createFromBuffer); + +var _Tag_createLightweight = _Tag.createLightweight; +_Tag.createLightweight = promisify(_Tag_createLightweight); + +var _Tag_delete = _Tag.delete; +_Tag.delete = promisify(_Tag_delete); + +var _Tag_dup = _Tag.prototype.dup; +_Tag.prototype.dup = promisify(_Tag_dup); + +var _Tag_list = _Tag.list; +_Tag.list = promisify(_Tag_list); + +var _Tag_listMatch = _Tag.listMatch; +_Tag.listMatch = promisify(_Tag_listMatch); + +var _Tag_lookup = _Tag.lookup; +_Tag.lookup = promisify(_Tag_lookup); + +var _Tag_lookupPrefix = _Tag.lookupPrefix; +_Tag.lookupPrefix = promisify(_Tag_lookupPrefix); + +var _Tag_peel = _Tag.prototype.peel; +_Tag.prototype.peel = promisify(_Tag_peel); + +var _Tag_target = _Tag.prototype.target; +_Tag.prototype.target = promisify(_Tag_target); + +var _Transaction = rawApi.Transaction; + +var _Transaction_create = _Transaction.create; +_Transaction.create = promisify(_Transaction_create); + +var _Tree = rawApi.Tree; + +var _Tree_createUpdated = _Tree.prototype.createUpdated; +_Tree.prototype.createUpdated = promisify(_Tree_createUpdated); + +var _Tree_dup = _Tree.prototype.dup; +_Tree.prototype.dup = promisify(_Tree_dup); + +var _Tree_entryByPath = _Tree.prototype.entryByPath; +_Tree.prototype.entryByPath = promisify(_Tree_entryByPath); + +var _Tree_lookup = _Tree.lookup; +_Tree.lookup = promisify(_Tree_lookup); + +var _Tree_lookupPrefix = _Tree.lookupPrefix; +_Tree.lookupPrefix = promisify(_Tree_lookupPrefix); + +var _TreeEntry = rawApi.TreeEntry; + +var _TreeEntry_toObject = _TreeEntry.prototype.toObject; +_TreeEntry.prototype.toObject = promisify(_TreeEntry_toObject); + +var _Treebuilder = rawApi.Treebuilder; + +var _Treebuilder_create = _Treebuilder.create; +_Treebuilder.create = promisify(_Treebuilder_create); + +var _Treebuilder_write = _Treebuilder.prototype.write; +_Treebuilder.prototype.write = promisify(_Treebuilder_write); + +var _Worktree = rawApi.Worktree; + +var _Worktree_add = _Worktree.add; +_Worktree.add = promisify(_Worktree_add); + +var _Worktree_list = _Worktree.list; +_Worktree.list = promisify(_Worktree_list); + +var _Worktree_lookup = _Worktree.lookup; +_Worktree.lookup = promisify(_Worktree_lookup); + +var _Worktree_openFromRepository = _Worktree.openFromRepository; +_Worktree.openFromRepository = promisify(_Worktree_openFromRepository); + +var _ConvenientPatch = rawApi.ConvenientPatch; +var _ConvenientPatch_hunks = _ConvenientPatch.prototype.hunks; +_ConvenientPatch.prototype.hunks = promisify(_ConvenientPatch_hunks); + +var _ConvenientHunk = rawApi.ConvenientHunk; +var _ConvenientHunk_lines = _ConvenientHunk.prototype.lines; +_ConvenientHunk.prototype.lines = promisify(_ConvenientHunk_lines); + +var _FilterRegistry = rawApi.FilterRegistry; +var _FilterRegistry_register = _FilterRegistry.register; +_FilterRegistry.register = promisify(_FilterRegistry_register); + +var _FilterRegistry_unregister = _FilterRegistry.unregister; +_FilterRegistry.unregister = promisify(_FilterRegistry_unregister); + +/* jshint ignore:end */ + +// Set the exports prototype to the raw API. +exports.__proto__ = rawApi; + +var importExtension = function importExtension(name) { + try { + require("./" + name); + } catch (unhandledException) { + if (unhandledException.code != "MODULE_NOT_FOUND") { + throw unhandledException; + } + } +}; + +// Load up utils +rawApi.Utils = {}; +require("./utils/lookup_wrapper"); +require("./utils/normalize_options"); +require("./utils/shallow_clone"); +require("./utils/normalize_fetch_options"); + +// Load up extra types; +require("./status_file"); +require("./enums.js"); + +// Import extensions +// [Manual] extensions +importExtension("filter_registry"); +importExtension("annotated_commit"); +importExtension("apply"); +importExtension("apply_options"); +importExtension("apply_options"); +importExtension("attr"); +importExtension("blame"); +importExtension("blame_hunk"); +importExtension("blame_options"); +importExtension("blob"); +importExtension("blob_filter_options"); +importExtension("blob_filter_options"); +importExtension("branch"); +importExtension("branch_iterator"); +importExtension("buf"); +importExtension("cert"); +importExtension("cert_hostkey"); +importExtension("cert_x509"); +importExtension("checkout"); +importExtension("checkout_options"); +importExtension("checkout_perfdata"); +importExtension("cherrypick"); +importExtension("cherrypick_options"); +importExtension("clone"); +importExtension("clone_options"); +importExtension("commit"); +importExtension("config"); +importExtension("config_entry"); +importExtension("config_entry"); +importExtension("config_iterator"); +importExtension("configmap"); +importExtension("cred"); +importExtension("describe_format_options"); +importExtension("describe_format_options"); +importExtension("describe_options"); +importExtension("describe_options"); +importExtension("describe_result"); +importExtension("diff"); +importExtension("diff_binary"); +importExtension("diff_binary_file"); +importExtension("diff_delta"); +importExtension("diff_file"); +importExtension("diff_find_options"); +importExtension("diff_hunk"); +importExtension("diff_line"); +importExtension("diff_options"); +importExtension("diff_patchid_options"); +importExtension("diff_perfdata"); +importExtension("diff_stats"); +importExtension("error"); +importExtension("fetch"); +importExtension("fetch_options"); +importExtension("fetch_options"); +importExtension("filter"); +importExtension("filter"); +importExtension("filter_list"); +importExtension("filter_source"); +importExtension("graph"); +importExtension("hashsig"); +importExtension("ignore"); +importExtension("index"); +importExtension("index_conflict_iterator"); +importExtension("index_entry"); +importExtension("index_iterator"); +importExtension("index_name_entry"); +importExtension("index_reuc_entry"); +importExtension("index_time"); +importExtension("indexer_progress"); +importExtension("libgit2"); +importExtension("mailmap"); +importExtension("merge"); +importExtension("merge_file_input"); +importExtension("merge_file_options"); +importExtension("merge_options"); +importExtension("note"); +importExtension("note_iterator"); +importExtension("object"); +importExtension("odb"); +importExtension("odb_object"); +importExtension("oid"); +importExtension("oid_shorten"); +importExtension("oidarray"); +importExtension("packbuilder"); +importExtension("patch"); +importExtension("path"); +importExtension("pathspec"); +importExtension("pathspec_match_list"); +importExtension("proxy"); +importExtension("proxy_options"); +importExtension("push_options"); +importExtension("push_update"); +importExtension("rebase"); +importExtension("rebase_operation"); +importExtension("rebase_options"); +importExtension("rebase_options"); +importExtension("refdb"); +importExtension("reference"); +importExtension("reflog"); +importExtension("reflog_entry"); +importExtension("refspec"); +importExtension("remote"); +importExtension("remote_callbacks"); +importExtension("remote_callbacks"); +importExtension("remote_create_options"); +importExtension("remote_create_options"); +importExtension("remote_head"); +importExtension("remote_head"); +importExtension("repository"); +importExtension("repository_init_options"); +importExtension("reset"); +importExtension("revert"); +importExtension("revert_options"); +importExtension("revparse"); +importExtension("revwalk"); +importExtension("signature"); +importExtension("stash"); +importExtension("stash_apply_options"); +importExtension("stash_apply_options"); +importExtension("status"); +importExtension("status_entry"); +importExtension("status_list"); +importExtension("status_options"); +importExtension("status_options"); +importExtension("strarray"); +importExtension("submodule"); +importExtension("submodule_update_options"); +importExtension("tag"); +importExtension("time"); +importExtension("trace"); +importExtension("transaction"); +importExtension("transport"); +importExtension("tree"); +importExtension("tree_entry"); +importExtension("tree_update"); +importExtension("treebuilder"); +importExtension("worktree"); +importExtension("worktree_add_options"); +importExtension("worktree_add_options"); +importExtension("worktree_prune_options"); +importExtension("worktree_prune_options"); +importExtension("writestream"); +/* jshint ignore:start */ + +// Inherit directly from the original Apply object. +_Apply.apply.__proto__ = _Apply; + +// Ensure we're using the correct prototype. +_Apply.apply.prototype = _Apply.prototype; + +// Assign the function as the root +rawApi.Apply = _Apply.apply; + +// Inherit directly from the original Cherrypick object. +_Cherrypick.cherrypick.__proto__ = _Cherrypick; + +// Ensure we're using the correct prototype. +_Cherrypick.cherrypick.prototype = _Cherrypick.prototype; + +// Assign the function as the root +rawApi.Cherrypick = _Cherrypick.cherrypick; + +// Inherit directly from the original Clone object. +_Clone.clone.__proto__ = _Clone; + +// Ensure we're using the correct prototype. +_Clone.clone.prototype = _Clone.prototype; + +// Assign the function as the root +rawApi.Clone = _Clone.clone; + +// Inherit directly from the original Merge object. +_Merge.merge.__proto__ = _Merge; + +// Ensure we're using the correct prototype. +_Merge.merge.prototype = _Merge.prototype; + +// Assign the function as the root +rawApi.Merge = _Merge.merge; + +// Inherit directly from the original Reset object. +_Reset.reset.__proto__ = _Reset; + +// Ensure we're using the correct prototype. +_Reset.reset.prototype = _Reset.prototype; + +// Assign the function as the root +rawApi.Reset = _Reset.reset; + +// Inherit directly from the original Revert object. +_Revert.revert.__proto__ = _Revert; + +// Ensure we're using the correct prototype. +_Revert.revert.prototype = _Revert.prototype; + +// Assign the function as the root +rawApi.Revert = _Revert.revert; + +/* jshint ignore:end */ + +// Wrap asynchronous methods to return promises. +promisify(exports); + +// Set version. +exports.version = require("../package").version; + +// Expose Promise implementation. +exports.Promise = Promise; \ No newline at end of file diff --git a/dist/note.js b/dist/note.js new file mode 100644 index 000000000..ebed9eadf --- /dev/null +++ b/dist/note.js @@ -0,0 +1,19 @@ +"use strict"; + +var NodeGit = require("../"); + +var Note = NodeGit.Note; + +var _foreach = Note.foreach; + +// Override Note.foreach to eliminate the need to pass null payload +Note.foreach = function (repo, notesRef, callback) { + function wrapperCallback(blobId, objectId) { + // We need to copy the OID since libgit2 types are getting cleaned up + // incorrectly right now in callbacks + + return callback(blobId.copy(), objectId.copy()); + } + + return _foreach(repo, notesRef, wrapperCallback, null); +}; \ No newline at end of file diff --git a/dist/object.js b/dist/object.js new file mode 100644 index 000000000..4d179dc14 --- /dev/null +++ b/dist/object.js @@ -0,0 +1,46 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); + +var Obj = NodeGit.Object; + +/** + * Is this object a blob? + * @return {Boolean} + */ +Obj.prototype.isBlob = function () { + return this.type() == Obj.TYPE.BLOB; +}; + +/** + * Is this object a commit? + * @return {Boolean} + */ +Obj.prototype.isCommit = function () { + return this.type() == Obj.TYPE.COMMIT; +}; + +/** + * Is this object a tag? + * @return {Boolean} + */ +Obj.prototype.isTag = function () { + return this.type() == Obj.TYPE.TAG; +}; + +/** + * Is this object a tree? + * @return {Boolean} + */ +Obj.prototype.isTree = function () { + return this.type() == Obj.TYPE.TREE; +}; + +// Deprecated ----------------------------------------------------------------- + +Object.defineProperty(Obj.TYPE, "BAD", { + get: util.deprecate(function () { + return Obj.TYPE.INVALID; + }, "Use NodeGit.Object.TYPE.INVALID instead of NodeGit.Object.TYPE.BAD.") +}); \ No newline at end of file diff --git a/dist/odb.js b/dist/odb.js new file mode 100644 index 000000000..5a4642e2b --- /dev/null +++ b/dist/odb.js @@ -0,0 +1,17 @@ +"use strict"; + +var NodeGit = require("../"); + +var Odb = NodeGit.Odb; + +var _read = Odb.prototype.read; + +Odb.prototype.read = function (oid, callback) { + return _read.call(this, oid).then(function (odbObject) { + if (typeof callback === "function") { + callback(null, odbObject); + } + + return odbObject; + }, callback); +}; \ No newline at end of file diff --git a/dist/odb_object.js b/dist/odb_object.js new file mode 100644 index 000000000..a5e3862e2 --- /dev/null +++ b/dist/odb_object.js @@ -0,0 +1,11 @@ +"use strict"; + +var NodeGit = require("../"); + +var OdbObject = NodeGit.OdbObject; + +OdbObject.prototype.toString = function (size) { + size = size || this.size(); + + return this.data().toBuffer(size).toString(); +}; \ No newline at end of file diff --git a/dist/oid.js b/dist/oid.js new file mode 100644 index 000000000..0ee1bc32a --- /dev/null +++ b/dist/oid.js @@ -0,0 +1,25 @@ +"use strict"; + +var NodeGit = require("../"); + +var Oid = NodeGit.Oid; + +// Backwards compatibility. +Object.defineProperties(Oid.prototype, { + "allocfmt": { + value: Oid.prototype.tostrS, + enumerable: false + }, + "toString": { + value: Oid.prototype.tostrS, + enumerable: false + } +}); + +Oid.prototype.copy = function () { + return this.cpy(); // seriously??? +}; + +Oid.prototype.inspect = function () { + return "[Oid " + this.allocfmt() + "]"; +}; \ No newline at end of file diff --git a/dist/rebase.js b/dist/rebase.js new file mode 100644 index 000000000..0cc64c705 --- /dev/null +++ b/dist/rebase.js @@ -0,0 +1,130 @@ +"use strict"; + +var NodeGit = require("../"); +var Rebase = NodeGit.Rebase; +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var shallowClone = NodeGit.Utils.shallowClone; + +var _init = Rebase.init; +var _open = Rebase.open; +var _abort = Rebase.prototype.abort; +var _commit = Rebase.prototype.commit; + +function defaultRebaseOptions(options, checkoutStrategy) { + var checkoutOptions = void 0; + var mergeOptions = void 0; + + if (options) { + options = shallowClone(options); + checkoutOptions = options.checkoutOptions; + mergeOptions = options.mergeOptions; + delete options.checkoutOptions; + delete options.mergeOptions; + + if (options.signingCb) { + var signingCb = options.signingCb; + options.signingCb = function (signatureBuf, signatureFieldBuf, commitContent) { + try { + var signingCbResult = signingCb(commitContent); + + return Promise.resolve(signingCbResult).then(function (_ref) { + var code = _ref.code, + field = _ref.field, + signedData = _ref.signedData; + + if (code === NodeGit.Error.CODE.OK) { + signatureBuf.setString(signedData); + if (field) { + signatureFieldBuf.setString(field); + } + } + + return code; + }).catch(function (error) { + if (error && error.code) { + return error.code; + } + return NodeGit.Error.CODE.ERROR; + }); + } catch (error) { + if (error && error.code) { + return error.code; + } + return NodeGit.Error.CODE.ERROR; + } + }; + } + + options = normalizeOptions(options, NodeGit.RebaseOptions); + } else { + options = normalizeOptions({}, NodeGit.RebaseOptions); + if (checkoutStrategy) { + checkoutOptions = { + checkoutStrategy: checkoutStrategy + }; + } + } + + if (checkoutOptions) { + options.checkoutOptions = normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions); + } + + if (mergeOptions) { + options.mergeOptions = normalizeOptions(mergeOptions, NodeGit.MergeOptions); + } + + return options; +} + +// Save options on the rebase object. If we don't do this, +// the options may be cleaned up and cause a segfault +// when Rebase.prototype.commit is called. +var lockOptionsOnRebase = function lockOptionsOnRebase(options) { + return function (rebase) { + Object.defineProperty(rebase, "options", { + value: options, + writable: false + }); + return rebase; + }; +}; + +/** + * Initializes a rebase + * @async + * @param {Repository} repo The repository to perform the rebase + * @param {AnnotatedCommit} branch The terminal commit to rebase, or NULL to + * rebase the current branch + * @param {AnnotatedCommit} upstream The commit to begin rebasing from, or NULL + * to rebase all reachable commits + * @param {AnnotatedCommit} onto The branch to rebase onto, or NULL to rebase + * onto the given upstream + * @param {RebaseOptions} options Options to specify how rebase is performed, + * or NULL + * @return {Remote} + */ +Rebase.init = function (repository, branch, upstream, onto, options) { + options = defaultRebaseOptions(options, NodeGit.Checkout.STRATEGY.FORCE); + return _init(repository, branch, upstream, onto, options).then(lockOptionsOnRebase(options)); +}; + +/** + * Opens an existing rebase that was previously started by either an invocation + * of Rebase.open or by another client. + * @async + * @param {Repository} repo The repository that has a rebase in-progress + * @param {RebaseOptions} options Options to specify how rebase is performed + * @return {Remote} + */ +Rebase.open = function (repository, options) { + options = defaultRebaseOptions(options, NodeGit.Checkout.STRATEGY.SAFE); + return _open(repository, options).then(lockOptionsOnRebase(options)); +}; + +Rebase.prototype.commit = function (author, committer, encoding, message) { + return _commit.call(this, author, committer, encoding, message); +}; + +Rebase.prototype.abort = function () { + return _abort.call(this); +}; \ No newline at end of file diff --git a/dist/reference.js b/dist/reference.js new file mode 100644 index 000000000..a0e98c59f --- /dev/null +++ b/dist/reference.js @@ -0,0 +1,196 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); +var LookupWrapper = NodeGit.Utils.lookupWrapper; + +var Reference = NodeGit.Reference; +var Branch = NodeGit.Branch; + +/** +* Retrieves the reference by it's short name +* @async +* @param {Repository} repo The repo that the reference lives in +* @param {String|Reference} id The reference to lookup +* @param {Function} callback +* @return {Reference} +*/ +Reference.dwim = LookupWrapper(Reference, Reference.dwim); + +/** +* Retrieves the reference pointed to by the oid +* @async +* @param {Repository} repo The repo that the reference lives in +* @param {String|Reference} id The reference to lookup +* @param {Function} callback +* @return {Reference} +*/ +Reference.lookup = LookupWrapper(Reference); + +/** + * Returns true if this reference is not symbolic + * @return {Boolean} + */ +Reference.prototype.isConcrete = function () { + return this.type() == Reference.TYPE.DIRECT; +}; + +/** + * Returns if the ref is pointed at by HEAD + * @return {Boolean} + */ +Reference.prototype.isHead = function () { + return Branch.isHead(this); +}; + +/** + * Returns true if this reference is symbolic + * @return {Boolean} + */ +Reference.prototype.isSymbolic = function () { + return this.type() == Reference.TYPE.SYMBOLIC; +}; + +/** + * Returns true if this reference is valid + * @return {Boolean} + */ +Reference.prototype.isValid = function () { + return this.type() != Reference.TYPE.INVALID; +}; + +/** + * Returns the name of the reference. + * @return {String} + */ +Reference.prototype.toString = function () { + return this.name(); +}; + +var getTerminal = function getTerminal(repo, refName) { + var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; + var prevRef = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + + if (depth <= 0) { + return Promise.resolve({ + error: NodeGit.Error.CODE.ENOTFOUND, + out: prevRef + }); + } + + return NodeGit.Reference.lookup(repo, refName).then(function (ref) { + if (ref.type() === NodeGit.Reference.TYPE.DIRECT) { + return { + error: NodeGit.Error.CODE.OK, + out: ref + }; + } else { + return getTerminal(repo, ref.symbolicTarget(), depth - 1, ref).then(function (_ref) { + var error = _ref.error, + out = _ref.out; + + if (error === NodeGit.Error.CODE.ENOTFOUND && !out) { + return { error: error, out: ref }; + } else { + return { error: error, out: out }; + } + }); + } + }).catch(function (error) { + return { + error: error.errno, + out: null + }; + }); +}; + +var getSignatureForReflog = function getSignatureForReflog(repo) { + var _repo$ident = repo.ident(), + email = _repo$ident.email, + name = _repo$ident.name; + + if (email && name) { + return Promise.resolve(NodeGit.Signature.now(name, email)); + } + + return NodeGit.Signature.default(repo).catch(function () { + return NodeGit.Signature.now("unknown", "unknown"); + }); +}; + +/** + * Given a reference name, follows symbolic links and updates the direct + * reference to point to a given OID. Updates the reflog with a given message. + * + * @async + * @param {Repository} repo The repo where the reference and objects live + * @param {String} refName The reference name to update + * @param {Oid} oid The target OID that the reference will point to + * @param {String} logMessage The reflog message to be writted + * @param {Signature} signature Optional signature to use for the reflog entry + */ +Reference.updateTerminal = function (repo, refName, oid, logMessage, signature) { + var signatureToUse = void 0; + var promiseChain = Promise.resolve(); + + if (!signature) { + promiseChain = promiseChain.then(function () { + return getSignatureForReflog(repo); + }).then(function (sig) { + signatureToUse = sig; + return Promise.resolve(); + }); + } else { + signatureToUse = signature; + } + + return promiseChain.then(function () { + return getTerminal(repo, refName); + }).then(function (_ref2) { + var error = _ref2.error, + out = _ref2.out; + + if (error === NodeGit.Error.CODE.ENOTFOUND && out) { + return NodeGit.Reference.create(repo, out.symbolicTarget(), oid, 0, logMessage); + } else if (error === NodeGit.Error.CODE.ENOTFOUND) { + return NodeGit.Reference.create(repo, refName, oid, 0, logMessage); + } else { + return NodeGit.Reference.createMatching(repo, out.name(), oid, 1, out.target(), logMessage); + } + }).then(function () { + return NodeGit.Reflog.read(repo, refName); + }).then(function (reflog) { + // Janky, but works. Ideally, we would want to generate the correct reflog + // entry in the first place, rather than drop the most recent entry and + // write the correct one. + // NOTE: There is a theoretical race condition that could happen here. + // We may want to consider some kind of transactional logic to make sure + // that the reflog on disk isn't modified before we can write back. + reflog.drop(0, 1); + reflog.append(oid, signatureToUse, logMessage); + return reflog.write(); + }); +}; + +// Deprecated ----------------------------------------------------------------- + +Object.defineProperty(NodeGit.Reference.TYPE, "OID", { + get: util.deprecate(function () { + return NodeGit.Reference.TYPE.DIRECT; + }, "Use NodeGit.Reference.TYPE.DIRECT instead of NodeGit.Reference.TYPE.OID.") +}); + +Object.defineProperty(NodeGit.Reference.TYPE, "LISTALL", { + get: util.deprecate(function () { + return NodeGit.Reference.TYPE.ALL; + }, "Use NodeGit.Reference.TYPE.ALL instead of NodeGit.Reference.TYPE.LISTALL.") +}); + +NodeGit.Reference.NORMALIZE = {}; +Object.keys(NodeGit.Reference.FORMAT).forEach(function (key) { + Object.defineProperty(NodeGit.Reference.NORMALIZE, "REF_FORMAT_" + key, { + get: util.deprecate(function () { + return NodeGit.Reference.FORMAT[key]; + }, "Use NodeGit.Reference.FORMAT." + key + " instead of " + ("NodeGit.Reference.NORMALIZE.REF_FORMAT_" + key + ".")) + }); +}); \ No newline at end of file diff --git a/dist/remote.js b/dist/remote.js new file mode 100644 index 000000000..8145c6100 --- /dev/null +++ b/dist/remote.js @@ -0,0 +1,214 @@ +"use strict"; + +var util = require("util"); +var NodeGit = require("../"); +var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions; +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var lookupWrapper = NodeGit.Utils.lookupWrapper; +var shallowClone = NodeGit.Utils.shallowClone; + +var Remote = NodeGit.Remote; +var _connect = Remote.prototype.connect; +var _createWithOpts = Remote.createWithOpts; +var _download = Remote.prototype.download; +var _fetch = Remote.prototype.fetch; +var _push = Remote.prototype.push; +var _updateTips = Remote.prototype.updateTips; +var _upload = Remote.prototype.upload; + +/** + * Retrieves the remote by name + * @async + * @param {Repository} repo The repo that the remote lives in + * @param {String|Remote} name The remote to lookup + * @param {Function} callback + * @return {Remote} + */ +Remote.lookup = lookupWrapper(Remote); + +/** + * Connects to a remote + * + * @async + * @param {Enums.DIRECTION} direction The direction for the connection + * @param {RemoteCallbacks} callbacks The callback functions for the connection + * @param {ProxyOptions} proxyOpts Proxy settings + * @param {Array} customHeaders extra HTTP headers to use + * @param {Function} callback + * @return {Number} error code + */ +Remote.prototype.connect = function (direction, callbacks, proxyOpts, customHeaders) { + callbacks = normalizeOptions(callbacks || {}, NodeGit.RemoteCallbacks); + proxyOpts = normalizeOptions(proxyOpts || {}, NodeGit.ProxyOptions); + customHeaders = customHeaders || []; + + return _connect.call(this, direction, callbacks, proxyOpts, customHeaders); +}; + +Remote.createWithOpts = function (url, options) { + return _createWithOpts(url, normalizeOptions(options, NodeGit.RemoteCreateOptions)); +}; + +/** + * Connects to a remote + * + * @async + * @param {Array} refSpecs The ref specs that should be pushed + * @param {FetchOptions} opts The fetch options for download, contains callbacks + * @param {Function} callback + * @return {Number} error code + */ +Remote.prototype.download = function (refspecs, opts) { + return _download.call(this, refspecs, normalizeFetchOptions(opts)); +}; + +/** + * Connects to a remote + * + * @async + * @param {Array} refSpecs The ref specs that should be pushed + * @param {FetchOptions} opts The fetch options for download, contains callbacks + * @param {String} message The message to use for the update reflog messages + * @param {Function} callback + * @return {Number} error code + */ +Remote.prototype.fetch = function (refspecs, opts, reflog_message) { + return _fetch.call(this, refspecs, normalizeFetchOptions(opts), reflog_message); +}; + +/** + * Pushes to a remote + * + * @async + * @param {Array} refSpecs The ref specs that should be pushed + * @param {PushOptions} options Options for the checkout + * @param {Function} callback + * @return {Number} error code + */ +Remote.prototype.push = function (refSpecs, opts) { + var callbacks; + var proxyOpts; + + if (opts) { + opts = shallowClone(opts); + callbacks = opts.callbacks; + proxyOpts = opts.proxyOpts; + delete opts.callbacks; + delete opts.proxyOpts; + } else { + opts = {}; + } + + opts = normalizeOptions(opts, NodeGit.PushOptions); + + if (callbacks) { + opts.callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks); + } + + if (proxyOpts) { + opts.proxyOpts = normalizeOptions(proxyOpts, NodeGit.ProxyOptions); + } + + return _push.call(this, refSpecs, opts); +}; + +/** + * Lists advertised references from a remote. You must connect to the remote + * before using referenceList. + * + * @async + * @return {Promise>} a list of the remote heads the remote + * had available at the last established + * connection. + * + */ +Remote.prototype.referenceList = Remote.prototype.referenceList; + +/** + * Connects to a remote + * + * @async + * @param {Array} refSpecs The ref specs that should be pushed + * @param {FetchOptions} opts The fetch options for download, contains callbacks + * @param {String} message The message to use for the update reflog messages + * @param {Function} callback + * @return {Number} error code + */ +Remote.prototype.fetch = function (refspecs, opts, reflog_message) { + return _fetch.call(this, refspecs, normalizeFetchOptions(opts), reflog_message); +}; + +/** + * Update the tips to the new state + * @param {RemoteCallbacks} callbacks The callback functions for the connection + * @param {boolean} updateFetchhead whether to write to FETCH_HEAD. Pass true + * to behave like git. + * @param {boolean} downloadTags what the behaviour for downloading tags is + * for this fetch. This is ignored for push. + * This must be the same value passed to + * Remote.prototype.download + * @param {string} reflogMessage The message to insert into the reflogs. If + * null and fetching, the default is "fetch ", + * where is the name of the remote (or its url, + * for in-memory remotes). This parameter is + * ignored when pushing. + */ +Remote.prototype.updateTips = function (callbacks, updateFetchhead, downloadTags, reflogMessage) { + if (callbacks) { + callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks); + } + + return _updateTips.call(this, callbacks, updateFetchhead, downloadTags, reflogMessage); +}; + +/** + * Pushes to a remote + * + * @async + * @param {Array} refSpecs The ref specs that should be pushed + * @param {PushOptions} options Options for the checkout + * @param {Function} callback + * @return {Number} error code + */ +Remote.prototype.upload = function (refSpecs, opts) { + var callbacks; + var proxyOpts; + + if (opts) { + opts = shallowClone(opts); + callbacks = opts.callbacks; + proxyOpts = opts.proxyOpts; + delete opts.callbacks; + delete opts.proxyOpts; + } else { + opts = {}; + } + + opts = normalizeOptions(opts, NodeGit.PushOptions); + + if (callbacks) { + opts.callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks); + } + + if (proxyOpts) { + opts.proxyOpts = normalizeOptions(proxyOpts, NodeGit.ProxyOptions); + } + + return _upload.call(this, refSpecs, opts); +}; + +NodeGit.Remote.COMPLETION_TYPE = {}; +var DEPRECATED_STATES = { + COMPLETION_DOWNLOAD: "DOWNLOAD", + COMPLETION_INDEXING: "INDEXING", + COMPLETION_ERROR: "ERROR" +}; + +Object.keys(DEPRECATED_STATES).forEach(function (key) { + var newKey = DEPRECATED_STATES[key]; + Object.defineProperty(NodeGit.Remote.COMPLETION_TYPE, key, { + get: util.deprecate(function () { + return NodeGit.Remote.COMPLETION[newKey]; + }, "Use NodeGit.Remote.COMPLETION." + newKey + " instead of " + ("NodeGit.Remote.COMPLETION_TYPE." + key + ".")) + }); +}); \ No newline at end of file diff --git a/dist/repository.js b/dist/repository.js new file mode 100644 index 000000000..5cd990724 --- /dev/null +++ b/dist/repository.js @@ -0,0 +1,1723 @@ +"use strict"; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } + +var fse = require("fs-extra"); +var fp = require("lodash/fp"); +var NodeGit = require("../"); +var Blob = NodeGit.Blob; +var Checkout = NodeGit.Checkout; +var Commit = NodeGit.Commit; +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var shallowClone = NodeGit.Utils.shallowClone; +var path = require("path"); +var Filter = NodeGit.Filter; +var FilterList = NodeGit.FilterList; +var Reference = NodeGit.Reference; +var Remote = NodeGit.Remote; +var Repository = NodeGit.Repository; +var Revwalk = NodeGit.Revwalk; +var Status = NodeGit.Status; +var StatusFile = NodeGit.StatusFile; +var StatusList = NodeGit.StatusList; +var Submodule = NodeGit.Submodule; +var Tag = NodeGit.Tag; +var Tree = NodeGit.Tree; +var TreeBuilder = NodeGit.Treebuilder; + +var _discover = Repository.discover; +var _initExt = Repository.initExt; +var _fetchheadForeach = Repository.prototype.fetchheadForeach; +var _mergeheadForeach = Repository.prototype.mergeheadForeach; + +function applySelectedLinesToTarget(originalContent, newLines, pathHunks, isStaged, reverse) { + // 43: ascii code for '+' + // 45: ascii code for '-' + var lineTypes = { + ADDED: !reverse ? 43 : 45, + DELETED: !reverse ? 45 : 43 + }; + var newContent = ""; + var oldIndex = 0; + var linesPromises = []; + + var oldLines = originalContent.toString().split("\n"); + + // if no selected lines were sent, return the original content + if (!newLines || newLines.length === 0) { + return originalContent; + } + + function lineEqualsFirstNewLine(hunkLine) { + return hunkLine.oldLineno() === newLines[0].oldLineno() && hunkLine.newLineno() === newLines[0].newLineno(); + } + + function processSelectedLine(hunkLine) { + // if this hunk line is a selected line find the selected line + var newLine = newLines.filter(function (nLine) { + return hunkLine.oldLineno() === nLine.oldLineno() && hunkLine.newLineno() === nLine.newLineno(); + }); + + if (hunkLine.content().indexOf("\\ No newline at end of file") !== -1) { + return false; + } + + // determine what to add to the new content + if (isStaged && newLine && newLine.length > 0 || !isStaged && (!newLine || newLine.length === 0)) { + if (hunkLine.origin() !== lineTypes.ADDED) { + newContent += hunkLine.content(); + } + if (isStaged && hunkLine.origin() !== lineTypes.DELETED || !isStaged && hunkLine.origin() !== lineTypes.ADDED) { + oldIndex++; + } + } else { + switch (hunkLine.origin()) { + case lineTypes.ADDED: + newContent += hunkLine.content(); + if (isStaged) { + oldIndex++; + } + break; + case lineTypes.DELETED: + if (!isStaged) { + oldIndex++; + } + break; + default: + newContent += oldLines[oldIndex++]; + if (oldIndex < oldLines.length) { + newContent += "\n"; + } + break; + } + } + } + + // find the affected hunk + pathHunks.forEach(function (pathHunk) { + linesPromises.push(pathHunk.lines()); + }); + + return Promise.all(linesPromises).then(function (results) { + for (var i = 0; i < results.length && newContent.length < 1; i++) { + var hunkStart = isStaged || reverse ? pathHunks[i].newStart() : pathHunks[i].oldStart(); + var lines = results[i]; + if (lines.filter(lineEqualsFirstNewLine).length > 0) { + // add content that is before the hunk + while (hunkStart > oldIndex + 1) { + newContent += oldLines[oldIndex++] + "\n"; + } + + // modify the lines of the hunk according to the selection + lines.forEach(processSelectedLine); + + // add the rest of the file + while (oldLines.length > oldIndex) { + newContent += oldLines[oldIndex++] + (oldLines.length > oldIndex ? "\n" : ""); + } + } + } + + return newContent; + }); +} + +function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) { + var diffOptions = additionalDiffOptions ? { + flags: additionalDiffOptions + } : undefined; + + return Promise.resolve().then(function () { + if (isStaged) { + return repo.getHeadCommit().then(function getTreeFromCommit(commit) { + return commit.getTree(); + }).then(function getDiffFromTree(tree) { + return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); + }); + } + + return NodeGit.Diff.indexToWorkdir(repo, index, { + flags: NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | (additionalDiffOptions || 0) + }); + }).then(function (diff) { + return NodeGit.Status.file(repo, filePath).then(function (status) { + if (!(status & NodeGit.Status.STATUS.WT_MODIFIED) && !(status & NodeGit.Status.STATUS.INDEX_MODIFIED)) { + return Promise.reject("Selected staging is only available on modified files."); + } + return diff.patches(); + }); + }).then(function (patches) { + var pathPatch = patches.filter(function (patch) { + return patch.newFile().path() === filePath; + }); + + if (pathPatch.length !== 1) { + return Promise.reject("No differences found for this file."); + } + + return pathPatch[0].hunks(); + }); +} + +function getReflogMessageForCommit(commit) { + var parentCount = commit.parentcount(); + var summary = commit.summary(); + var commitType; + + if (parentCount >= 2) { + commitType = " (merge)"; + } else if (parentCount == 0) { + commitType = " (initial)"; + } else { + commitType = ""; + } + + return "commit" + commitType + ": " + summary; +} + +/** + * Goes through a rebase's rebase operations and commits them if there are + * no merge conflicts + * + * @param {Repository} repository The repository that the rebase is being + * performed in + * @param {Rebase} rebase The current rebase being performed + * @param {Signature} signature Identity of the one performing the rebase + * @param {Function} beforeNextFn Callback to be called before each + * invocation of next(). If the callback + * returns a promise, the next() will be + * called when the promise resolves. + * @param {Function} beforeFinishFn Callback called before the invocation + * of finish(). If the callback returns a + * promise, finish() will be called when the + * promise resolves. This callback will be + * provided a detailed overview of the rebase + * @return {Int|Index} An error code for an unsuccesful rebase or an index for + * a rebase with conflicts + */ +function performRebase(repository, rebase, signature, beforeNextFn, beforeFinishFn) { + var beforeNextFnResult; + + /* In the case of FF merges and a beforeFinishFn, this will fail + * when looking for 'rewritten' so we need to handle that case. + */ + function readRebaseMetadataFile(fileName, continueOnError) { + return fse.readFile(path.join(repository.path(), "rebase-merge", fileName), { encoding: "utf8" }).then(fp.trim).catch(function (err) { + if (continueOnError) { + return null; + } + throw err; + }); + } + + function calcHeadName(input) { + return input.replace(/refs\/heads\/(.*)/, "$1"); + } + + function getPromise() { + return rebase.next().then(function () { + return repository.refreshIndex(); + }).then(function (index) { + if (index.hasConflicts()) { + throw index; + } + + return rebase.commit(null, signature); + }).then(function () { + + return performRebase(repository, rebase, signature, beforeNextFn, beforeFinishFn); + }).catch(function (error) { + if (error && error.errno === NodeGit.Error.CODE.ITEROVER) { + var calcRewritten = fp.cond([[fp.isEmpty, fp.constant(null)], [fp.stubTrue, fp.flow([fp.split("\n"), fp.map(fp.split(" "))])]]); + + var beforeFinishFnPromise = !beforeFinishFn ? Promise.resolve() : Promise.all([readRebaseMetadataFile("onto_name"), readRebaseMetadataFile("onto"), readRebaseMetadataFile("head-name").then(calcHeadName), readRebaseMetadataFile("orig-head"), readRebaseMetadataFile("rewritten", true).then(calcRewritten)]).then(function (_ref) { + var _ref2 = _slicedToArray(_ref, 5), + ontoName = _ref2[0], + ontoSha = _ref2[1], + originalHeadName = _ref2[2], + originalHeadSha = _ref2[3], + rewritten = _ref2[4]; + + return beforeFinishFn({ + ontoName: ontoName, + ontoSha: ontoSha, + originalHeadName: originalHeadName, + originalHeadSha: originalHeadSha, + rebase: rebase, + rewritten: rewritten + }); + }); + + return beforeFinishFnPromise.then(function () { + return rebase.finish(signature); + }); + } else { + throw error; + } + }); + } + + if (beforeNextFn) { + beforeNextFnResult = beforeNextFn(rebase); + // if beforeNextFn returns a promise, chain the promise + return Promise.resolve(beforeNextFnResult).then(getPromise); + } + + return getPromise(); +} + +/** + * Creates a branch with the passed in name pointing to the commit + * + * @async + * @param {String} startPath The base path where the lookup starts. + * @param {Number} acrossFs If non-zero, then the lookup will not stop when a + filesystem device change is detected while exploring + parent directories. + * @param {String} ceilingDirs A list of absolute symbolic link free paths. + the search will stop if any of these paths + are hit. This may be set to null + * @return {String} Path of the git repository + */ +Repository.discover = function (startPath, acrossFs, ceilingDirs, callback) { + return _discover(startPath, acrossFs, ceilingDirs).then(function (foundPath) { + foundPath = path.resolve(foundPath); + if (typeof callback === "function") { + callback(null, foundPath); + } + return foundPath; + }, callback); +}; + +// Override Repository.initExt to normalize initoptions +Repository.initExt = function (repo_path, opts) { + opts = normalizeOptions(opts, NodeGit.RepositoryInitOptions); + return _initExt(repo_path, opts); +}; + +Repository.getReferences = function (repo, type, refNamesOnly) { + return repo.getReferences().then(function (refList) { + var filteredRefList = refList.filter(function (reference) { + return type === Reference.TYPE.ALL || reference.type === type; + }); + + if (refNamesOnly) { + return filteredRefList.map(function (reference) { + return reference.name(); + }); + } + + return filteredRefList; + }); +}; + +/** + * This will set the HEAD to point to the local branch and then attempt + * to update the index and working tree to match the content of the + * latest commit on that branch + * + * @async + * @param {String|Reference} branch the branch to checkout + * @param {Object|CheckoutOptions} opts the options to use for the checkout + */ +Repository.prototype.checkoutBranch = function (branch, opts) { + var repo = this; + + return repo.getReference(branch).then(function (ref) { + if (!ref.isBranch()) { + return false; + } + return repo.checkoutRef(ref, opts); + }); +}; + +/** + * This will set the HEAD to point to the reference and then attempt + * to update the index and working tree to match the content of the + * latest commit on that reference + * + * @async + * @param {Reference} reference the reference to checkout + * @param {Object|CheckoutOptions} opts the options to use for the checkout + */ +Repository.prototype.checkoutRef = function (reference, opts) { + var repo = this; + opts = opts || {}; + + opts.checkoutStrategy = opts.checkoutStrategy || NodeGit.Checkout.STRATEGY.SAFE | NodeGit.Checkout.STRATEGY.RECREATE_MISSING; + return repo.getReferenceCommit(reference.name()).then(function (commit) { + return commit.getTree(); + }).then(function (tree) { + return Checkout.tree(repo, tree, opts); + }).then(function () { + var name = reference.name(); + return repo.setHead(name); + }); +}; + +/** + * Continues an existing rebase + * + * @async + * @param {Signature} signature Identity of the one performing the rebase + * @param {Function} beforeNextFn Callback to be called before each step + * of the rebase. If the callback returns a + * promise, the rebase will resume when the + * promise resolves. The rebase object is + * is passed to the callback. + * @param {Function} beforeFinishFn Callback called before the invocation + * of finish(). If the callback returns a + * promise, finish() will be called when the + * promise resolves. This callback will be + * provided a detailed overview of the rebase + * @param {RebaseOptions} rebaseOptions Options to initialize the rebase object + * with + * @return {Oid|Index} A commit id for a succesful merge or an index for a + * rebase with conflicts + */ +Repository.prototype.continueRebase = function (signature, beforeNextFn, beforeFinishFn, rebaseOptions) { + var repo = this; + + var rebase = void 0; + var promiseChain = Promise.resolve(); + + if (!signature) { + promiseChain = promiseChain.then(function () { + return repo.defaultSignature(); + }).then(function (signatureResult) { + signature = signatureResult; + }); + } + + return promiseChain.then(function () { + return repo.refreshIndex(); + }).then(function (index) { + if (index.hasConflicts()) { + throw index; + } + + return NodeGit.Rebase.open(repo, rebaseOptions); + }).then(function (_rebase) { + rebase = _rebase; + return rebase.commit(null, signature).catch(function (e) { + // If the first commit on continueRebase is a + // "patch already applied" error, + // interpret that as an explicit "skip commit" + // and ignore the error. + var errno = fp.get(["errno"], e); + if (errno === NodeGit.Error.CODE.EAPPLIED) { + return; + } + + throw e; + }); + }).then(function () { + return performRebase(repo, rebase, signature, beforeNextFn, beforeFinishFn); + }).then(function (error) { + if (error) { + throw error; + } + + return repo.getBranchCommit("HEAD"); + }); +}; + +/** + * Creates a branch with the passed in name pointing to the commit + * + * @async + * @param {String} name Branch name, e.g. "master" + * @param {Commit|String|Oid} commit The commit the branch will point to + * @param {Boolean} force Overwrite branch if it exists + * @return {Reference} + */ +Repository.prototype.createBranch = function (name, commit, force) { + var repo = this; + + if (commit instanceof Commit) { + return NodeGit.Branch.create(repo, name, commit, force ? 1 : 0); + } else { + return repo.getCommit(commit).then(function (commit) { + return NodeGit.Branch.create(repo, name, commit, force ? 1 : 0); + }); + } +}; + +/** + * Create a blob from a buffer + * + * @async + * @param {Buffer} buffer + * @return {Oid} + */ +Repository.prototype.createBlobFromBuffer = function (buffer) { + return Blob.createFromBuffer(this, buffer, buffer.length); +}; + +/** + * Create a commit + * + * @async + * @param {String} updateRef + * @param {Signature} author + * @param {Signature} committer + * @param {String} message + * @param {Oid|String} Tree + * @param {Array} parents + * @return {Oid} The oid of the commit + */ +Repository.prototype.createCommit = function (updateRef, author, committer, message, tree, parents, callback) { + + var repo = this; + var promises = []; + + parents = parents || []; + + promises.push(repo.getTree(tree)); + + parents.forEach(function (parent) { + promises.push(repo.getCommit(parent)); + }); + + return Promise.all(promises).then(function (results) { + tree = results[0]; + + // Get the normalized values for our input into the function + var parentsLength = parents.length; + parents = []; + + for (var i = 0; i < parentsLength; i++) { + parents.push(results[i + 1]); + } + + return Commit.create(repo, updateRef, author, committer, null /* use default message encoding */ + , message, tree, parents.length, parents); + }).then(function (commit) { + if (typeof callback === "function") { + callback(null, commit); + } + + return commit; + }, callback); +}; + +/** + * Create a commit + * + * @async + * @param {Signature} author + * @param {Signature} committer + * @param {String} message + * @param {Oid|String} treeOid + * @param {Array} parents + * @return {String} The content of the commit object + * as a string + */ +Repository.prototype.createCommitBuffer = function (author, committer, message, treeOid, parents) { + + var repo = this; + var promises = (parents || []).reduce(function (acc, parent) { + acc.push(repo.getCommit(parent)); + return acc; + }, [repo.getTree(treeOid)]); + + return Promise.all(promises).then(function (_ref3) { + var _ref4 = _toArray(_ref3), + tree = _ref4[0], + parentCommits = _ref4.slice(1); + + return Commit.createBuffer(repo, author, committer, null /* use default message encoding */ + , message, tree, parentCommits.length, parentCommits); + }); +}; + +/** + * Create a commit that is digitally signed + * + * @async + * @param {String} updateRef + * @param {Signature} author + * @param {Signature} committer + * @param {String} message + * @param {Tree|Oid|String} Tree + * @param {Array} parents + * @param {Function} onSignature Callback to be called with string to be signed + * @return {Oid} The oid of the commit + */ +Repository.prototype.createCommitWithSignature = function (updateRef, author, committer, message, tree, parents, onSignature) { + + var repo = this; + var promises = []; + var commitContent; + var skippedSigning; + + parents = parents || []; + + promises.push(repo.getTree(tree)); + + parents.forEach(function (parent) { + promises.push(repo.getCommit(parent)); + }); + + var createCommitPromise = Promise.all(promises).then(function (results) { + tree = results[0]; + + // Get the normalized values for our input into the function + var parentsLength = parents.length; + parents = []; + + for (var i = 0; i < parentsLength; i++) { + parents.push(results[i + 1]); + } + + return Commit.createBuffer(repo, author, committer, null /* use default message encoding */ + , message, tree, parents.length, parents); + }).then(function (commitContentResult) { + commitContent = commitContentResult; + if (!commitContent.endsWith("\n")) { + commitContent += "\n"; + } + return onSignature(commitContent); + }).then(function (_ref5) { + var code = _ref5.code, + field = _ref5.field, + signedData = _ref5.signedData; + + switch (code) { + case NodeGit.Error.CODE.OK: + return Commit.createWithSignature(repo, commitContent, signedData, field); + case NodeGit.Error.CODE.PASSTHROUGH: + skippedSigning = true; + return Commit.create(repo, updateRef, author, committer, null /* use default message encoding */ + , message, tree, parents.length, parents); + default: + { + var error = new Error("Repository.prototype.createCommitWithSignature " + ("threw with error code " + code)); + error.errno = code; + throw error; + } + } + }); + + if (!updateRef) { + return createCommitPromise; + } + + return createCommitPromise.then(function (commitOid) { + if (skippedSigning) { + return commitOid; + } + + return repo.getCommit(commitOid).then(function (commitResult) { + return Reference.updateTerminal(repo, updateRef, commitOid, getReflogMessageForCommit(commitResult), committer); + }).then(function () { + return commitOid; + }); + }); +}; + +/** + * Creates a new commit on HEAD from the list of passed in files + * + * @async + * @param {Array} filesToAdd + * @param {Signature} author + * @param {Signature} committer + * @param {String} message + * @return {Oid} The oid of the new commit + */ +Repository.prototype.createCommitOnHead = function (filesToAdd, author, committer, message, callback) { + + var repo = this; + + return repo.refreshIndex().then(function (index) { + if (!filesToAdd) { + filesToAdd = []; + } + + return filesToAdd.reduce(function (lastFilePromise, filePath) { + return lastFilePromise.then(function () { + return index.addByPath(filePath); + }); + }, Promise.resolve()).then(function () { + return index.write(); + }).then(function () { + return index.writeTree(); + }); + }).then(function (treeOid) { + return repo.getHeadCommit().then(function (parent) { + if (parent !== null) { + // To handle a fresh repo with no commits + parent = [parent]; + } + return repo.createCommit("HEAD", author, committer, message, treeOid, parent); + }); + }, callback); +}; + +/** + * Creates a new lightweight tag + * + * @async + * @param {String|Oid} String sha or Oid + * @param {String} name the name of the tag + * @return {Reference} + */ +Repository.prototype.createLightweightTag = function (oid, name, callback) { + var repository = this; + + return Commit.lookup(repository, oid).then(function (commit) { + // Final argument is `force` which overwrites any previous tag + return Tag.createLightweight(repository, name, commit, 0); + }).then(function () { + return Reference.lookup(repository, "refs/tags/" + name); + }); +}; + +/** + * Instantiate a new revision walker for browsing the Repository"s history. + * See also `Commit.prototype.history()` + * + * @return {Revwalk} + */ +Repository.prototype.createRevWalk = function () { + return Revwalk.create(this); +}; + +/** + * Creates a new annotated tag + * + * @async + * @param {String|Oid} String sha or Oid + * @param {String} name the name of the tag + * @param {String} message the description that will be attached to the + * annotated tag + * @return {Tag} + */ +Repository.prototype.createTag = function (oid, name, message, callback) { + var repository = this; + var signature = null; + + return repository.defaultSignature().then(function (signatureResult) { + signature = signatureResult; + return Commit.lookup(repository, oid); + }).then(function (commit) { + // Final argument is `force` which overwrites any previous tag + return Tag.create(repository, name, commit, signature, message, 0); + }).then(function (tagOid) { + return repository.getTag(tagOid, callback); + }); +}; + +/** + * Gets the default signature for the default user and now timestamp + * + * @async + * @return {Signature} + */ +Repository.prototype.defaultSignature = function () { + return NodeGit.Signature.default(this).then(function (result) { + if (!result || !result.name()) { + result = NodeGit.Signature.now("unknown", "unknown@example.com"); + } + return result; + }).catch(function () { + return NodeGit.Signature.now("unknown", "unknown@example.com"); + }); +}; + +/** + * Deletes a tag from a repository by the tag name. + * + * @async + * @param {String} Short or full tag name + */ +Repository.prototype.deleteTagByName = function (name) { + var repository = this; + + name = ~name.indexOf("refs/tags/") ? name.substr(10) : name; + + return Tag.delete(repository, name); +}; + +/** + * Discard line selection of a specified file. + * Assumes selected lines are unstaged. + * + * @async + * @param {String} filePath The relative path of this file in the repo + * @param {Array} selectedLines The array of DiffLine objects + * selected for discarding + * @return {Number} 0 or an error code + */ +Repository.prototype.discardLines = function (filePath, selectedLines, additionalDiffOptions) { + var repo = this; + var fullFilePath = path.join(repo.workdir(), filePath); + var index; + var originalContent; + var filterList; + + return repo.refreshIndex().then(function (indexResult) { + index = indexResult; + return FilterList.load(repo, null, filePath, Filter.MODE.CLEAN, Filter.FLAG.DEFAULT); + }).then(function (_filterList) { + filterList = _filterList; + + if (filterList) { + return filterList.applyToFile(repo, filePath); + } + + return fse.readFile(fullFilePath, "utf8"); + }).then(function (content) { + originalContent = content; + return getPathHunks(repo, index, filePath, false, additionalDiffOptions); + }).then(function (hunks) { + return applySelectedLinesToTarget(originalContent, selectedLines, hunks, false, true); + }).then(function (newContent) { + return FilterList.load(repo, null, filePath, Filter.MODE.SMUDGE, Filter.FLAG.DEFAULT).then(function (_filterList) { + filterList = _filterList; + if (filterList) { + /* jshint ignore:start */ + // We need the constructor for the check in NodeGit's C++ layer + // to accept an object, and this seems to be a nice way to do it + return filterList.applyToData(new String(newContent)); + /* jshint ignore:end */ + } + + return newContent; + }); + }).then(function (filteredContent) { + return fse.writeFile(fullFilePath, filteredContent); + }); +}; + +/** + * Fetches from a remote + * + * @async + * @param {String|Remote} remote + * @param {Object|FetchOptions} fetchOptions Options for the fetch, includes + * callbacks for fetching + */ +Repository.prototype.fetch = function (remote, fetchOptions, callback) { + var repo = this; + + function finallyFn(error) { + if (typeof callback === "function") { + callback(error); + } + } + + return repo.getRemote(remote).then(function (remote) { + return remote.fetch(null, fetchOptions, "Fetch from " + remote).then(function () { + return remote.disconnect(); + }); + }).then(finallyFn).catch(function (error) { + finallyFn(error); + throw error; + }); +}; + +/** + * Fetches from all remotes. This is done in series due to deadlocking issues + * with fetching from many remotes that can happen. + * + * @async + * @param {Object|FetchOptions} fetchOptions Options for the fetch, includes + * callbacks for fetching + * @param {Function} callback + */ +Repository.prototype.fetchAll = function (fetchOptions, callback) { + var repo = this; + + function createCallbackWrapper(fn, remote) { + return function () { + var args = Array.prototype.slice.call(arguments); + args.push(remote); + + return fn.apply(this, args); + }.bind(this); + } + + fetchOptions = fetchOptions || {}; + + var remoteCallbacks = fetchOptions.callbacks || {}; + + var credentials = remoteCallbacks.credentials; + var certificateCheck = remoteCallbacks.certificateCheck; + var transferProgress = remoteCallbacks.transferProgress; + + return repo.getRemoteNames().then(function (remotes) { + return remotes.reduce(function (fetchPromise, remote) { + var wrappedFetchOptions = shallowClone(fetchOptions); + var wrappedRemoteCallbacks = shallowClone(remoteCallbacks); + + if (credentials) { + wrappedRemoteCallbacks.credentials = createCallbackWrapper(credentials, remote); + } + + if (certificateCheck) { + wrappedRemoteCallbacks.certificateCheck = createCallbackWrapper(certificateCheck, remote); + } + + if (transferProgress) { + wrappedRemoteCallbacks.transferProgress = createCallbackWrapper(transferProgress, remote); + } + + wrappedFetchOptions.callbacks = wrappedRemoteCallbacks; + + return fetchPromise.then(function () { + return repo.fetch(remote, wrappedFetchOptions); + }); + }, Promise.resolve()); + }).then(function () { + if (typeof callback === "function") { + callback(); + } + }); +}; + +/** + * @async + * @param {FetchheadForeachCb} callback The callback function to be called on + * each entry + */ +Repository.prototype.fetchheadForeach = function (callback) { + return _fetchheadForeach.call(this, callback, null); +}; + +/** + * Retrieve the blob represented by the oid. + * + * @async + * @param {String|Oid} String sha or Oid + * @return {Blob} + */ +Repository.prototype.getBlob = function (oid, callback) { + var repository = this; + + return Blob.lookup(repository, oid).then(function (blob) { + blob.repo = repository; + + if (typeof callback === "function") { + callback(null, blob); + } + + return blob; + }, callback); +}; + +/** +* Look up a branch. Alias for `getReference` +* +* @async +* @param {String|Reference} name Ref name, e.g. "master", "refs/heads/master" +* or Branch Ref +* @return {Reference} +*/ +Repository.prototype.getBranch = function (name, callback) { + return this.getReference(name, callback); +}; + +/** +* Look up a branch's most recent commit. Alias to `getReferenceCommit` +* +* @async +* @param {String|Reference} name Ref name, e.g. "master", "refs/heads/master" +* or Branch Ref +* @return {Commit} +*/ +Repository.prototype.getBranchCommit = function (name, callback) { + return this.getReferenceCommit(name, callback); +}; + +/** + * Retrieve the commit identified by oid. + * + * @async + * @param {String|Oid} String sha or Oid + * @return {Commit} + */ +Repository.prototype.getCommit = function (oid, callback) { + var repository = this; + + return Commit.lookup(repository, oid).then(function (commit) { + if (typeof callback === "function") { + callback(null, commit); + } + + return commit; + }, callback); +}; + +/** + * Gets the branch that HEAD currently points to + * Is an alias to head() + * + * @async + * @return {Reference} + */ +Repository.prototype.getCurrentBranch = function () { + return this.head(); +}; + +/** + * Retrieve the commit that HEAD is currently pointing to + * + * @async + * @return {Commit} + */ +Repository.prototype.getHeadCommit = function (callback) { + var repo = this; + + return Reference.nameToId(repo, "HEAD").then(function (head) { + return repo.getCommit(head, callback); + }).catch(function () { + return null; + }); +}; + +/** + * Retrieve the master branch commit. + * + * @async + * @return {Commit} + */ +Repository.prototype.getMasterCommit = function (callback) { + return this.getBranchCommit("master", callback); +}; + +/** + * Lookup the reference with the given name. + * + * @async + * @param {String|Reference} name Ref name, e.g. "master", "refs/heads/master" + * or Branch Ref + * @return {Reference} + */ +Repository.prototype.getReference = function (name, callback) { + var repository = this; + + return Reference.dwim(this, name).then(function (reference) { + if (reference.isSymbolic()) { + return reference.resolve().then(function (reference) { + reference.repo = repository; + + if (typeof callback === "function") { + callback(null, reference); + } + + return reference; + }, callback); + } else { + reference.repo = repository; + if (typeof callback === "function") { + callback(null, reference); + } + return reference; + } + }, callback); +}; + +/** + * Look up a refs's commit. + * + * @async + * @param {String|Reference} name Ref name, e.g. "master", "refs/heads/master" + * or Branch Ref + * @return {Commit} + */ +Repository.prototype.getReferenceCommit = function (name, callback) { + var repository = this; + + return this.getReference(name).then(function (reference) { + return repository.getCommit(reference.target()).then(function (commit) { + if (typeof callback === "function") { + callback(null, commit); + } + + return commit; + }); + }, callback); +}; + +/** + * Lookup reference names for a repository. + * + * @async + * @param {Reference.TYPE} type Type of reference to look up + * @return {Array} + */ +Repository.prototype.getReferenceNames = function (type) { + return Repository.getReferences(this, type, true); +}; + +/** + * Lookup references for a repository. + * + * @async + * @param {Reference.TYPE} type Type of reference to look up + * @return {Array} + */ + +/** + * Gets a remote from the repo + * + * @async + * @param {String|Remote} remote + * @param {Function} callback + * @return {Remote} The remote object + */ +Repository.prototype.getRemote = function (remote, callback) { + if (remote instanceof NodeGit.Remote) { + return Promise.resolve(remote).then(function (remoteObj) { + if (typeof callback === "function") { + callback(null, remoteObj); + } + + return remoteObj; + }, callback); + } + + return NodeGit.Remote.lookup(this, remote).then(function (remoteObj) { + if (typeof callback === "function") { + callback(null, remoteObj); + } + + return remoteObj; + }, callback); +}; + +/** +* Lists out the remotes in the given repository. +* +* @async +* @param {Function} Optional callback +* @return {Object} Promise object. +*/ +Repository.prototype.getRemoteNames = function (callback) { + return Remote.list(this).then(function (remotes) { + if (typeof callback === "function") { + callback(null, remotes); + } + + return remotes; + }, callback); +}; + +/** + * Get the status of a repo to it's working directory + * + * @async + * @param {obj} opts + * @return {Array} + */ +Repository.prototype.getStatus = function (opts) { + var statuses = []; + var statusCallback = function statusCallback(path, status) { + statuses.push(new StatusFile({ path: path, status: status })); + }; + + if (!opts) { + opts = { + flags: Status.OPT.INCLUDE_UNTRACKED | Status.OPT.RECURSE_UNTRACKED_DIRS + }; + } + + return Status.foreachExt(this, opts, statusCallback).then(function () { + return statuses; + }); +}; + +/** + * Get extended statuses of a repo to it's working directory. Status entries + * have `status`, `headToIndex` delta, and `indexToWorkdir` deltas + * + * @async + * @param {obj} opts + * @return {Array} + */ +Repository.prototype.getStatusExt = function (opts) { + var statuses = []; + + if (!opts) { + opts = { + flags: Status.OPT.INCLUDE_UNTRACKED | Status.OPT.RECURSE_UNTRACKED_DIRS | Status.OPT.RENAMES_INDEX_TO_WORKDIR | Status.OPT.RENAMES_HEAD_TO_INDEX | Status.OPT.RENAMES_FROM_REWRITES + }; + } + + return StatusList.create(this, opts).then(function (list) { + for (var i = 0; i < list.entrycount(); i++) { + var entry = Status.byIndex(list, i); + statuses.push(new StatusFile({ entry: entry })); + } + + return statuses; + }); +}; + +/** + * Get the names of the submodules in the repository. + * + * @async + * @return {Array} + */ +Repository.prototype.getSubmoduleNames = function (callback) { + var names = []; + var submoduleCallback = function submoduleCallback(submodule, name, payload) { + names.push(name); + }; + + return Submodule.foreach(this, submoduleCallback).then(function () { + if (typeof callback === "function") { + callback(null, names); + } + + return names; + }); +}; + +/** + * Retrieve the tag represented by the oid. + * + * @async + * @param {String|Oid} String sha or Oid + * @return {Tag} + */ +Repository.prototype.getTag = function (oid, callback) { + var repository = this; + + return Tag.lookup(repository, oid).then(function (reference) { + reference.repo = repository; + + if (typeof callback === "function") { + callback(null, reference); + } + + return reference; + }, callback); +}; + +/** + * Retrieve the tag represented by the tag name. + * + * @async + * @param {String} Short or full tag name + * @return {Tag} + */ +Repository.prototype.getTagByName = function (name, callback) { + var repo = this; + + name = ~name.indexOf("refs/tags/") ? name : "refs/tags/" + name; + + return Reference.nameToId(repo, name).then(function (oid) { + return Tag.lookup(repo, oid).then(function (reference) { + reference.repo = repo; + + if (typeof callback === "function") { + callback(null, reference); + } + + return reference; + }); + }, callback); +}; + +/** + * Retrieve the tree represented by the oid. + * + * @async + * @param {String|Oid} String sha or Oid + * @return {Tree} + */ +Repository.prototype.getTree = function (oid, callback) { + var repository = this; + + return Tree.lookup(repository, oid).then(function (tree) { + tree.repo = repository; + + if (typeof callback === "function") { + callback(null, tree); + } + + return tree; + }, callback); +}; + +/** + * Returns true if the repository is in the APPLY_MAILBOX or + * APPLY_MAILBOX_OR_REBASE state. + * @return {Boolean} + */ +Repository.prototype.isApplyingMailbox = function () { + var state = this.state(); + return state === NodeGit.Repository.STATE.APPLY_MAILBOX || state === NodeGit.Repository.STATE.APPLY_MAILBOX_OR_REBASE; +}; + +/** + * Returns true if the repository is in the BISECT state. + * @return {Boolean} + */ +Repository.prototype.isBisecting = function () { + return this.state() === NodeGit.Repository.STATE.BISECT; +}; + +/** + * Returns true if the repository is in the CHERRYPICK state. + * @return {Boolean} + */ +Repository.prototype.isCherrypicking = function () { + return this.state() === NodeGit.Repository.STATE.CHERRYPICK; +}; + +/** + * Returns true if the repository is in the default NONE state. + * @return {Boolean} + */ +Repository.prototype.isDefaultState = function () { + return this.state() === NodeGit.Repository.STATE.NONE; +}; + +/** + * Returns true if the repository is in the MERGE state. + * @return {Boolean} + */ +Repository.prototype.isMerging = function () { + return this.state() === NodeGit.Repository.STATE.MERGE; +}; + +/** + * Returns true if the repository is in the REBASE, REBASE_INTERACTIVE, or + * REBASE_MERGE state. + * @return {Boolean} + */ +Repository.prototype.isRebasing = function () { + var state = this.state(); + return state === NodeGit.Repository.STATE.REBASE || state === NodeGit.Repository.STATE.REBASE_INTERACTIVE || state === NodeGit.Repository.STATE.REBASE_MERGE; +}; + +/** + * Returns true if the repository is in the REVERT state. + * @return {Boolean} + */ +Repository.prototype.isReverting = function () { + return this.state() === NodeGit.Repository.STATE.REVERT; +}; + +/** + * Rebases a branch onto another branch + * + * @async + * @param {String} branch + * @param {String} upstream + * @param {String} onto + * @param {Signature} signature Identity of the one performing the rebase + * @param {Function} beforeNextFn Callback to be called before each step + * of the rebase. If the callback returns a + * promise, the rebase will resume when the + * promise resolves. The rebase object is + * is passed to the callback. + * @param {Function} beforeFinishFn Callback called before the invocation + * of finish(). If the callback returns a + * promise, finish() will be called when the + * promise resolves. This callback will be + * provided a detailed overview of the rebase + * @param {RebaseOptions} rebaseOptions Options to initialize the rebase object + * with + * @return {Oid|Index} A commit id for a succesful merge or an index for a + * rebase with conflicts + */ +Repository.prototype.rebaseBranches = function (branch, upstream, onto, signature, beforeNextFn, beforeFinishFn, rebaseOptions) { + var repo = this; + var branchCommit = void 0; + var upstreamCommit = void 0; + var ontoCommit = void 0; + var mergeOptions = (rebaseOptions || {}).mergeOptions; + + var promiseChain = Promise.resolve(); + + if (!signature) { + promiseChain = promiseChain.then(function () { + return repo.defaultSignature(); + }).then(function (signatureResult) { + signature = signatureResult; + }); + } + + return Promise.all([repo.getReference(branch), upstream ? repo.getReference(upstream) : null, onto ? repo.getReference(onto) : null]).then(function (refs) { + return Promise.all([NodeGit.AnnotatedCommit.fromRef(repo, refs[0]), upstream ? NodeGit.AnnotatedCommit.fromRef(repo, refs[1]) : null, onto ? NodeGit.AnnotatedCommit.fromRef(repo, refs[2]) : null]); + }).then(function (annotatedCommits) { + branchCommit = annotatedCommits[0]; + upstreamCommit = annotatedCommits[1]; + ontoCommit = annotatedCommits[2]; + + return NodeGit.Merge.base(repo, branchCommit.id(), upstreamCommit.id()); + }).then(function (oid) { + if (oid.toString() === branchCommit.id().toString()) { + // we just need to fast-forward + return repo.mergeBranches(branch, upstream, null, null, mergeOptions).then(function () { + // checkout 'branch' to match the behavior of rebase + return repo.checkoutBranch(branch); + }); + } else if (oid.toString() === upstreamCommit.id().toString()) { + // 'branch' is already on top of 'upstream' + // checkout 'branch' to match the behavior of rebase + return repo.checkoutBranch(branch); + } + + return NodeGit.Rebase.init(repo, branchCommit, upstreamCommit, ontoCommit, rebaseOptions).then(function (rebase) { + return performRebase(repo, rebase, signature, beforeNextFn, beforeFinishFn); + }).then(function (error) { + if (error) { + throw error; + } + }); + }).then(function () { + return repo.getBranchCommit("HEAD"); + }); +}; + +/** + * Grabs a fresh copy of the index from the repository. Invalidates + * all previously grabbed indexes + * + * @async + * @return {Index} + */ +Repository.prototype.refreshIndex = function (callback) { + var repo = this; + + repo.setIndex(); // clear the index + + return repo.index().then(function (index) { + if (typeof callback === "function") { + callback(null, index); + } + + return index; + }, callback); +}; + +/** + * Merge a branch onto another branch + * + * @async + * @param {String|Reference} to + * @param {String|Reference} from + * @param {Signature} signature + * @param {Merge.PREFERENCE} mergePreference + * @param {MergeOptions} mergeOptions + * @param {MergeBranchOptions} mergeBranchOptions + * @return {Oid|Index} A commit id for a succesful merge or an index for a + * merge with conflicts + */ +Repository.prototype.mergeBranches = function (to, from, signature, mergePreference, mergeOptions, mergeBranchOptions) { + var repo = this; + var fromBranch = void 0; + var toBranch = void 0; + // Support old parameter `processMergeMessageCallback` + var isOldOptionParameter = typeof mergeBranchOptions === "function"; + if (isOldOptionParameter) { + console.error("DeprecationWarning: Repository#mergeBranches parameter " + "processMergeMessageCallback, use MergeBranchOptions"); + } + var processMergeMessageCallback = mergeBranchOptions && (isOldOptionParameter ? mergeBranchOptions : mergeBranchOptions.processMergeMessageCallback) || function (message) { + return message; + }; + var signingCallback = mergeBranchOptions && mergeBranchOptions.signingCb; + + mergePreference = mergePreference || NodeGit.Merge.PREFERENCE.NONE; + mergeOptions = normalizeOptions(mergeOptions, NodeGit.MergeOptions); + + var promiseChain = Promise.resolve(); + + if (!signature) { + promiseChain = promiseChain.then(function () { + return repo.defaultSignature(); + }).then(function (signatureResult) { + signature = signatureResult; + }); + } + + return promiseChain.then(function () { + return Promise.all([repo.getBranch(to), repo.getBranch(from)]); + }).then(function (objects) { + toBranch = objects[0]; + fromBranch = objects[1]; + + return Promise.all([repo.getBranchCommit(toBranch), repo.getBranchCommit(fromBranch)]); + }).then(function (branchCommits) { + var toCommitOid = branchCommits[0].toString(); + var fromCommitOid = branchCommits[1].toString(); + + return NodeGit.Merge.base(repo, toCommitOid, fromCommitOid).then(function (baseCommit) { + if (baseCommit.toString() == fromCommitOid) { + // The commit we're merging to is already in our history. + // nothing to do so just return the commit the branch is on + return toCommitOid; + } else if (baseCommit.toString() == toCommitOid && mergePreference !== NodeGit.Merge.PREFERENCE.NO_FASTFORWARD) { + // fast forward + var message = "Fast forward branch " + toBranch.shorthand() + " to branch " + fromBranch.shorthand(); + + return branchCommits[1].getTree().then(function (tree) { + if (toBranch.isHead()) { + // Checkout the tree if we're on the branch + var opts = { + checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE | NodeGit.Checkout.STRATEGY.RECREATE_MISSING + }; + return NodeGit.Checkout.tree(repo, tree, opts); + } + }).then(function () { + return toBranch.setTarget(fromCommitOid, message).then(function () { + return fromCommitOid; + }); + }); + } else if (mergePreference !== NodeGit.Merge.PREFERENCE.FASTFORWARD_ONLY) { + var updateHead; + // We have to merge. Lets do it! + return NodeGit.Reference.lookup(repo, "HEAD").then(function (headRef) { + return headRef.resolve(); + }).then(function (headRef) { + updateHead = !!headRef && headRef.name() === toBranch.name(); + return NodeGit.Merge.commits(repo, toCommitOid, fromCommitOid, mergeOptions); + }).then(function (index) { + // if we have conflicts then throw the index + if (index.hasConflicts()) { + throw index; + } + + // No conflicts so just go ahead with the merge + return index.writeTreeTo(repo); + }).then(function (oid) { + var mergeDecorator; + if (fromBranch.isTag()) { + mergeDecorator = "tag"; + } else if (fromBranch.isRemote()) { + mergeDecorator = "remote-tracking branch"; + } else { + mergeDecorator = "branch"; + } + + var message = "Merge " + mergeDecorator + " '" + fromBranch.shorthand() + "'"; + + // https://github.com/git/git/blob/master/builtin/fmt-merge-msg.c#L456-L459 + if (toBranch.shorthand() !== "master") { + message += " into " + toBranch.shorthand(); + } + + return Promise.all([oid, processMergeMessageCallback(message)]); + }).then(function (_ref6) { + var _ref7 = _slicedToArray(_ref6, 2), + oid = _ref7[0], + message = _ref7[1]; + + if (signingCallback) { + return repo.createCommitWithSignature(toBranch.name(), signature, signature, message, oid, [toCommitOid, fromCommitOid], signingCallback); + } + return repo.createCommit(toBranch.name(), signature, signature, message, oid, [toCommitOid, fromCommitOid]); + }).then(function (commit) { + // we've updated the checked out branch, so make sure we update + // head so that our index isn't messed up + if (updateHead) { + return repo.getBranch(to).then(function (branch) { + return repo.getBranchCommit(branch); + }).then(function (branchCommit) { + return branchCommit.getTree(); + }).then(function (tree) { + var opts = { + checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE | NodeGit.Checkout.STRATEGY.RECREATE_MISSING + }; + return NodeGit.Checkout.tree(repo, tree, opts); + }).then(function () { + return commit; + }); + } else { + return commit; + } + }); + } else { + // A non fast-forwardable merge with ff-only + return toCommitOid; + } + }); + }); +}; + +/** + * @async + * @param {MergeheadForeachCb} callback The callback function to be called on + * each entry + */ +Repository.prototype.mergeheadForeach = function (callback) { + return _mergeheadForeach.call(this, callback, null); +}; + +/** + * Stages or unstages line selection of a specified file + * + * @async + * @param {String|Array} filePath The relative path of this file in the repo + * @param {Boolean} stageNew Set to stage new filemode. Unset to unstage. + * @return {Number} 0 or an error code + */ +Repository.prototype.stageFilemode = function (filePath, stageNew, additionalDiffOptions) { + var repo = this; + var index; + var diffOptions = additionalDiffOptions ? { + flags: additionalDiffOptions + } : undefined; + var diffPromise = stageNew ? NodeGit.Diff.indexToWorkdir(repo, index, { + flags: NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | (additionalDiffOptions || 0) + }) : repo.getHeadCommit().then(function getTreeFromCommit(commit) { + return commit.getTree(); + }).then(function getDiffFromTree(tree) { + return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); + }); + var filePaths = filePath instanceof Array ? filePath : [filePath]; + + var indexLock = repo.path().replace(".git/", "") + ".git/index.lock"; + + return fse.remove(indexLock).then(function () { + return repo.refreshIndex(); + }).then(function (indexResult) { + index = indexResult; + }).then(function () { + return diffPromise; + }).then(function (diff) { + var origLength = filePaths.length; + var fileFilterPromises = fp.map(function (p) { + return NodeGit.Status.file(repo, p).then(function (status) { + return { + path: p, + filter: status & NodeGit.Status.STATUS.WT_MODIFIED || status & NodeGit.Status.STATUS.INDEX_MODIFIED + }; + }); + }, filePaths); + + return Promise.all(fileFilterPromises).then(function (results) { + filePaths = fp.flow([fp.filter(function (filterResult) { + return filterResult.filter; + }), fp.map(function (filterResult) { + return filterResult.path; + })])(results); + + if (filePaths.length === 0 && origLength > 0) { + return Promise.reject("Selected staging is only available on modified files."); + } + return diff.patches(); + }); + }).then(function (patches) { + var pathPatches = patches.filter(function (patch) { + return ~filePaths.indexOf(patch.newFile().path()); + }); + if (pathPatches.length === 0) { + return Promise.reject("No differences found for this file."); + } + + return pathPatches.reduce(function (lastIndexAddPromise, pathPatch) { + var entry = index.getByPath(pathPatch.newFile().path(), 0); + + entry.mode = stageNew ? pathPatch.newFile().mode() : pathPatch.oldFile().mode(); + + return lastIndexAddPromise.then(function () { + return index.add(entry); + }); + }, Promise.resolve()); + }).then(function () { + return index.write(); + }); +}; + +/** + * Stages or unstages line selection of a specified file + * + * @async + * @param {String} filePath The relative path of this file in the repo + * @param {Array} selectedLines The array of DiffLine objects + * selected for staging or unstaging + * @param {Boolean} isStaged Are the selected lines currently staged + * @return {Number} 0 or an error code + */ +Repository.prototype.stageLines = function (filePath, selectedLines, isSelectionStaged, additionalDiffOptions) { + + var repo = this; + var index; + var originalBlob; + + // The following chain checks if there is a patch with no hunks left for the + // file, and no filemode changes were done on the file. It is then safe to + // stage the entire file so the file doesn't show as having unstaged changes + // in `git status`. Also, check if there are no type changes. + var lastHunkStagedPromise = function lastHunkStagedPromise(result) { + return NodeGit.Diff.indexToWorkdir(repo, index, { + flags: NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | (additionalDiffOptions || 0) + }).then(function (diff) { + return diff.patches(); + }).then(function (patches) { + var pathPatch = patches.filter(function (patch) { + return patch.newFile().path() === filePath; + }); + var emptyPatch = false; + if (pathPatch.length > 0) { + // No hunks, unchanged file mode, and no type changes. + emptyPatch = pathPatch[0].size() === 0 && pathPatch[0].oldFile().mode() === pathPatch[0].newFile().mode() && !pathPatch[0].isTypeChange(); + } + if (emptyPatch) { + return index.addByPath(filePath).then(function () { + return index.write(); + }); + } + + return result; + }); + }; + + return repo.refreshIndex().then(function (indexResult) { + index = indexResult; + var pathOid = index.getByPath(filePath).id; + + return repo.getBlob(pathOid); + }).then(function (blob) { + originalBlob = blob; + + return getPathHunks(repo, index, filePath, isSelectionStaged, additionalDiffOptions); + }).then(function (hunks) { + return applySelectedLinesToTarget(originalBlob, selectedLines, hunks, isSelectionStaged); + }).then(function (newContent) { + var newContentBuffer = new Buffer(newContent); + + return repo.createBlobFromBuffer(newContentBuffer); + }).then(function (newOid) { + return repo.getBlob(newOid); + }).then(function (newBlob) { + var entry = index.getByPath(filePath, 0); + entry.id = newBlob.id(); + entry.path = filePath; + entry.fileSize = newBlob.content().length; + + return index.add(entry); + }).then(function () { + return index.write(); + }).then(function (result) { + if (isSelectionStaged) { + return result; + } + + return lastHunkStagedPromise(result); + }); +}; + +/** + * Create a new tree builder. + * + * @param {Tree} tree + */ +Repository.prototype.treeBuilder = function () { + var builder = TreeBuilder.create(null); + + builder.root = builder; + builder.repo = this; + + return builder; +}; \ No newline at end of file diff --git a/dist/reset.js b/dist/reset.js new file mode 100644 index 000000000..41bff5e31 --- /dev/null +++ b/dist/reset.js @@ -0,0 +1,78 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Reset = NodeGit.Reset; +var _default = Reset.default; +var _reset = Reset.reset; +var _fromAnnotated = Reset.fromAnnotated; + +/** + * Look up a refs's commit. + * + * @async + * @param {Repository} repo Repository where to perform the reset operation. + * @param {Commit|Tag} target The committish which content will be used to reset + * the content of the index. + * @param {Strarray} pathspecs List of pathspecs to operate on. + * + * @return {Number} 0 on success or an error code + */ +Reset.default = function (repo, target, pathspecs) { + return _default.call(this, repo, target, pathspecs); +}; + +/** + * Reset a repository's current HEAD to the specified target. + * + * @async + * @param {Repository} repo Repository where to perform the reset operation. + * + * @param {Commit|Tag} target Committish to which the Head should be moved to. + * This object must belong to the given `repo` and can + * either be a git_commit or a git_tag. When a git_tag is + * being passed, it should be dereferencable to a + * git_commit which oid will be used as the target of the + * branch. + * @param {Number} resetType Kind of reset operation to perform. + * + * @param {CheckoutOptions} opts Checkout options to be used for a HARD reset. + * The checkout_strategy field will be overridden + * (based on reset_type). This parameter can be + * used to propagate notify and progress + * callbacks. + * + * @return {Number} 0 on success or an error code + */ +Reset.reset = function (repo, target, resetType, opts) { + opts = normalizeOptions(opts, NodeGit.CheckoutOptions); + if (repo !== target.repo) { + // this is the same that is performed on libgit2's side + // https://github.com/nodegit/libgit2/blob/8d89e409616831b7b30a5ca7b89354957137b65e/src/reset.c#L120-L124 + throw new Error("Repository and target commit's repository does not match"); + } + return _reset.call(this, repo, target, resetType, opts); +}; + +/** + * Sets the current head to the specified commit oid and optionally + * resets the index and working tree to match. + * + * This behaves like reset but takes an annotated commit, which lets + * you specify which extended sha syntax string was specified by a + * user, allowing for more exact reflog messages. + * + * See the documentation for reset. + * + * @async + * @param {Repository} repo + * @param {AnnotatedCommit} target + * @param {Number} resetType + * @param {CheckoutOptions} opts + */ +Reset.fromAnnotated = function (repo, target, resetType, opts) { + opts = normalizeOptions(opts, NodeGit.CheckoutOptions); + + return _fromAnnotated.call(this, repo, target, resetType, opts); +}; \ No newline at end of file diff --git a/dist/revert.js b/dist/revert.js new file mode 100644 index 000000000..4cf5306a3 --- /dev/null +++ b/dist/revert.js @@ -0,0 +1,69 @@ +"use strict"; + +var NodeGit = require("../"); +var shallowClone = NodeGit.Utils.shallowClone; +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Revert = NodeGit.Revert; +var _commit = Revert.commit; +var _revert = Revert.revert; + +/** + * Reverts the given commit against the given "our" commit, producing an index + * that reflects the result of the revert. + * + * @async + * @param {Repository} repo the repository that contains the given commits. + * @param {Commit} revert_commit the commit to revert + * @param {Commit} our_commit the commit to revert against (e.g. HEAD) + * @param {Number} mainline the parent of the revert commit, if it is a merge + * @param {MergeOptions} merge_options the merge options (or null for defaults) + * + * @return {Index} the index result + */ +Revert.commit = function (repo, revert_commit, our_commit, mainline, merge_options, callback) { + merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions); + + return _commit.call(this, repo, revert_commit, our_commit, mainline, merge_options).then(function (result) { + if (typeof callback === "function") { + callback(null, result); + } + + return result; + }, callback); +}; + +/** + * Reverts the given commit, producing changes in the index and + * working directory. + * + * @async + * @param {Repository} repo the repository to perform the revert in + * @param {Commit} commit the commit to revert + * @param {RevertOptions} revert_options the revert options + * (or null for defaults) + */ +Revert.revert = function (repo, commit, revertOpts) { + var mergeOpts; + var checkoutOpts; + + if (revertOpts) { + revertOpts = shallowClone(revertOpts); + mergeOpts = revertOpts.mergeOpts; + checkoutOpts = revertOpts.checkoutOpts; + delete revertOpts.mergeOpts; + delete revertOpts.checkoutOpts; + } + + revertOpts = normalizeOptions(revertOpts, NodeGit.RevertOptions); + + if (mergeOpts) { + revertOpts.mergeOpts = normalizeOptions(mergeOpts, NodeGit.MergeOptions); + } + + if (checkoutOpts) { + revertOpts.checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions); + } + + return _revert.call(this, repo, commit, revertOpts); +}; \ No newline at end of file diff --git a/dist/revwalk.js b/dist/revwalk.js new file mode 100644 index 000000000..33b54d34a --- /dev/null +++ b/dist/revwalk.js @@ -0,0 +1,146 @@ +"use strict"; + +var NodeGit = require("../"); +var Revwalk = NodeGit.Revwalk; + +Object.defineProperty(Revwalk.prototype, "repo", { + get: function get() { + return this.repository(); + }, + configurable: true +}); + +var _sorting = Revwalk.prototype.sorting; +/** + * @typedef historyEntry + * @type {Object} + * @property {Commit} commit the commit for this entry + * @property {Number} status the status of the file in the commit + * @property {String} newName the new name that is provided when status is + * renamed + * @property {String} oldName the old name that is provided when status is + * renamed + */ +var fileHistoryWalk = Revwalk.prototype.fileHistoryWalk; +/** + * @param {String} filePath + * @param {Number} max_count + * @async + * @return {Array} + */ +Revwalk.prototype.fileHistoryWalk = fileHistoryWalk; + +/** + * Get a number of commits. + * + * @async + * @param {Number} count (default: 10) + * @return {Array} + */ +Revwalk.prototype.getCommits = function (count) { + count = count || 10; + var promises = []; + var walker = this; + + function walkCommitsCount(count) { + if (count === 0) { + return; + } + + return walker.next().then(function (oid) { + promises.push(walker.repo.getCommit(oid)); + return walkCommitsCount(count - 1); + }).catch(function (error) { + if (error.errno !== NodeGit.Error.CODE.ITEROVER) { + throw error; + } + }); + } + + return walkCommitsCount(count).then(function () { + return Promise.all(promises); + }); +}; + +/** + * Walk the history grabbing commits until the checkFn called with the + * current commit returns false. + * + * @async + * @param {Function} checkFn function returns false to stop walking + * @return {Array} + */ +Revwalk.prototype.getCommitsUntil = function (checkFn) { + var commits = []; + var walker = this; + + function walkCommitsCb() { + return walker.next().then(function (oid) { + return walker.repo.getCommit(oid).then(function (commit) { + commits.push(commit); + if (checkFn(commit)) { + return walkCommitsCb(); + } + }); + }).catch(function (error) { + if (error.errno !== NodeGit.Error.CODE.ITEROVER) { + throw error; + } + }); + } + + return walkCommitsCb().then(function () { + return commits; + }); +}; + +/** + * Set the sort order for the revwalk. This function takes variable arguments + * like `revwalk.sorting(NodeGit.RevWalk.Topological, NodeGit.RevWalk.Reverse).` + * + * @param {Number} sort + */ +Revwalk.prototype.sorting = function () { + var sort = 0; + + for (var i = 0; i < arguments.length; i++) { + sort |= arguments[i]; + } + + _sorting.call(this, sort); +}; + +/** + * Walk the history from the given oid. The callback is invoked for each commit; + * When the walk is over, the callback is invoked with `(null, null)`. + * + * @param {Oid} oid + * @param {Function} callback + */ +Revwalk.prototype.walk = function (oid, callback) { + var revwalk = this; + + this.push(oid); + + function walk() { + revwalk.next().done(function (oid) { + if (!oid) { + if (typeof callback === "function") { + return callback(); + } + + return; + } + + revwalk.repo.getCommit(oid).then(function (commit) { + if (typeof callback === "function") { + callback(null, commit); + } + + walk(); + }); + }, callback); + } + + walk(); +}; \ No newline at end of file diff --git a/dist/signature.js b/dist/signature.js new file mode 100644 index 000000000..7c8ecc740 --- /dev/null +++ b/dist/signature.js @@ -0,0 +1,40 @@ +"use strict"; + +var NodeGit = require("../"); +var Signature = NodeGit.Signature; + +var toPaddedDoubleDigitString = function toPaddedDoubleDigitString(number) { + if (number < 10) { + return "0" + number; + } + + return "" + number; +}; + +/** + * Standard string representation of an author. + * @param {Boolean} withTime Whether or not to include timestamp + * @return {String} Representation of the author. + */ +Signature.prototype.toString = function (withTime) { + var name = this.name().toString(); + var email = this.email().toString(); + + var stringifiedSignature = name + " <" + email + ">"; + + if (!withTime) { + return stringifiedSignature; + } + + var when = this.when(); + var offset = when.offset(); + var offsetMagnitude = Math.abs(offset); + var time = when.time(); + + var sign = offset < 0 || when.sign() === "-" ? "-" : "+"; + var hours = toPaddedDoubleDigitString(Math.floor(offsetMagnitude / 60)); + var minutes = toPaddedDoubleDigitString(offsetMagnitude % 60); + + stringifiedSignature += " " + time + " " + sign + hours + minutes; + return stringifiedSignature; +}; \ No newline at end of file diff --git a/dist/stash.js b/dist/stash.js new file mode 100644 index 000000000..1b195d3c8 --- /dev/null +++ b/dist/stash.js @@ -0,0 +1,62 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var shallowClone = NodeGit.Utils.shallowClone; +var Stash = NodeGit.Stash; + +var _apply = Stash.apply; +var _foreach = Stash.foreach; +var _pop = Stash.pop; + +Stash.apply = function (repo, index, options) { + var checkoutOptions; + + if (options) { + options = shallowClone(options); + checkoutOptions = options.checkoutOptions; + delete options.checkoutOptions; + } else { + options = {}; + } + + options = normalizeOptions(options, NodeGit.StashApplyOptions); + + if (checkoutOptions) { + options.checkoutOptions = normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions); + } + + return _apply(repo, index, options); +}; + +// Override Stash.foreach to eliminate the need to pass null payload +Stash.foreach = function (repo, callback) { + function wrappedCallback(index, message, oid) { + // We need to copy the OID since libgit2 types are getting cleaned up + // incorrectly right now in callbacks + + return callback(index, message, oid.copy()); + } + + return _foreach(repo, wrappedCallback, null); +}; + +Stash.pop = function (repo, index, options) { + var checkoutOptions; + + if (options) { + options = shallowClone(options); + checkoutOptions = options.checkoutOptions; + delete options.checkoutOptions; + } else { + options = {}; + } + + options = normalizeOptions(options, NodeGit.StashApplyOptions); + + if (checkoutOptions) { + options.checkoutOptions = normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions); + } + + return _pop(repo, index, options); +}; \ No newline at end of file diff --git a/dist/status.js b/dist/status.js new file mode 100644 index 000000000..35ee40ef5 --- /dev/null +++ b/dist/status.js @@ -0,0 +1,20 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var Status = NodeGit.Status; + +var _foreach = Status.foreach; +var _foreachExt = Status.foreachExt; + +// Override Status.foreach to eliminate the need to pass null payload +Status.foreach = function (repo, callback) { + return _foreach(repo, callback, null); +}; + +// Override Status.foreachExt to normalize opts +Status.foreachExt = function (repo, opts, callback) { + opts = normalizeOptions(opts, NodeGit.StatusOptions); + return _foreachExt(repo, opts, callback, null); +}; \ No newline at end of file diff --git a/dist/status_file.js b/dist/status_file.js new file mode 100644 index 000000000..29abc64ff --- /dev/null +++ b/dist/status_file.js @@ -0,0 +1,95 @@ +"use strict"; + +var NodeGit = require("../"); +var Status = NodeGit.Status; + +var StatusFile = function StatusFile(args) { + var path = args.path; + var status = args.status; + var entry = args.entry; + + if (entry) { + status = entry.status(); + if (entry.indexToWorkdir()) { + path = entry.indexToWorkdir().newFile().path(); + } else { + path = entry.headToIndex().newFile().path(); + } + } + + var codes = Status.STATUS; + + var getStatus = function getStatus() { + var fileStatuses = []; + + for (var key in Status.STATUS) { + if (status & Status.STATUS[key]) { + fileStatuses.push(key); + } + } + + return fileStatuses; + }; + + var data = { + path: path, + entry: entry, + statusBit: status, + statuses: getStatus() + }; + + return { + headToIndex: function headToIndex() { + if (data.entry) { + return entry.headToIndex(); + } else { + return undefined; + } + }, + indexToWorkdir: function indexToWorkdir() { + if (data.entry) { + return entry.indexToWorkdir(); + } else { + return undefined; + } + }, + inIndex: function inIndex() { + return status & codes.INDEX_NEW || status & codes.INDEX_MODIFIED || status & codes.INDEX_DELETED || status & codes.INDEX_TYPECHANGE || status & codes.INDEX_RENAMED; + }, + inWorkingTree: function inWorkingTree() { + return status & codes.WT_NEW || status & codes.WT_MODIFIED || status & codes.WT_DELETED || status & codes.WT_TYPECHANGE || status & codes.WT_RENAMED; + }, + isConflicted: function isConflicted() { + return status & codes.CONFLICTED; + }, + isDeleted: function isDeleted() { + return status & codes.WT_DELETED || status & codes.INDEX_DELETED; + }, + isIgnored: function isIgnored() { + return status & codes.IGNORED; + }, + isModified: function isModified() { + return status & codes.WT_MODIFIED || status & codes.INDEX_MODIFIED; + }, + isNew: function isNew() { + return status & codes.WT_NEW || status & codes.INDEX_NEW; + }, + isRenamed: function isRenamed() { + return status & codes.WT_RENAMED || status & codes.INDEX_RENAMED; + }, + isTypechange: function isTypechange() { + return status & codes.WT_TYPECHANGE || status & codes.INDEX_TYPECHANGE; + }, + path: function path() { + return data.path; + }, + status: function status() { + return data.statuses; + }, + statusBit: function statusBit() { + return data.statusBit; + } + }; +}; + +NodeGit.StatusFile = StatusFile; \ No newline at end of file diff --git a/dist/status_list.js b/dist/status_list.js new file mode 100644 index 000000000..2e428c875 --- /dev/null +++ b/dist/status_list.js @@ -0,0 +1,14 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; + +var StatusList = NodeGit.StatusList; + +var _create = StatusList.create; + +// Override StatusList.create to normalize opts +StatusList.create = function (repo, opts) { + opts = normalizeOptions(opts, NodeGit.StatusOptions); + return _create(repo, opts); +}; \ No newline at end of file diff --git a/dist/submodule.js b/dist/submodule.js new file mode 100644 index 000000000..a7a994146 --- /dev/null +++ b/dist/submodule.js @@ -0,0 +1,50 @@ +"use strict"; + +var NodeGit = require("../"); +var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions; +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var shallowClone = NodeGit.Utils.shallowClone; + +var Submodule = NodeGit.Submodule; + +var _foreach = Submodule.foreach; +var _update = Submodule.prototype.update; + +// Override Submodule.foreach to eliminate the need to pass null payload +Submodule.foreach = function (repo, callback) { + return _foreach(repo, callback, null); +}; + +/** + * Updates a submodule + * + * @async + * @param {Number} init Setting this to 1 will initialize submodule + * before updating + * @param {SubmoduleUpdateOptions} options Submodule update settings + * @return {Number} 0 on success, any non-zero return value from a callback + */ +Submodule.prototype.update = function (init, options) { + var fetchOpts; + var checkoutOpts; + + if (options) { + options = shallowClone(options); + fetchOpts = options.fetchOpts; + checkoutOpts = options.checkoutOpts; + delete options.fetchOpts; + delete options.checkoutOpts; + } + + options = normalizeOptions(options, NodeGit.SubmoduleUpdateOptions); + + if (fetchOpts) { + options.fetchOpts = normalizeFetchOptions(fetchOpts); + } + + if (checkoutOpts) { + options.checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions); + } + + return _update.call(this, init, options); +}; \ No newline at end of file diff --git a/dist/tag.js b/dist/tag.js new file mode 100644 index 000000000..db989ebfb --- /dev/null +++ b/dist/tag.js @@ -0,0 +1,134 @@ +"use strict"; + +var NodeGit = require("../"); +var LookupWrapper = NodeGit.Utils.lookupWrapper; +var Tag = NodeGit.Tag; + +var signatureRegexesBySignatureType = { + gpgsig: [/-----BEGIN PGP SIGNATURE-----[\s\S]+?-----END PGP SIGNATURE-----/gm, /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/gm], + x509: [/-----BEGIN SIGNED MESSAGE-----[\s\S]+?-----END SIGNED MESSAGE-----/gm] +}; + +/** + * Retrieves the tag pointed to by the oid + * @async + * @param {Repository} repo The repo that the tag lives in + * @param {String|Oid|Tag} id The tag to lookup + * @return {Tag} + */ +Tag.lookup = LookupWrapper(Tag); + +/** + * @async + * @param {Repository} repo + * @param {String} tagName + * @param {Oid} target + * @param {Signature} tagger + * @return {String} + */ +Tag.createBuffer = function (repo, tagName, target, tagger, message) { + return NodeGit.Object.lookup(repo, target, NodeGit.Object.TYPE.ANY).then(function (object) { + if (!NodeGit.Object.typeisloose(object.type())) { + throw new Error("Object must be a loose type"); + } + + var id = object.id().toString(); + var objectType = NodeGit.Object.type2String(object.type()); + var lines = ["object " + id, "type " + objectType, "tag " + tagName, "tagger " + tagger.toString(true) + "\n", "" + message + (message.endsWith("\n") ? "" : "\n")]; + return lines.join("\n"); + }); +}; + +/** + * @async + * @param {Repository} repo + * @param {String} tagName + * @param {Oid} target + * @param {Signature} tagger + * @param {String} message + * @param {Number} force + * @param {Function} signingCallback Takes a string and returns a string + * representing the signed message + * @return {Oid} + */ +Tag.createWithSignature = function (repo, tagName, target, tagger, message, force, signingCallback) { + var tagBuffer = void 0; + return Tag.createBuffer(repo, tagName, target, tagger, message).then(function (tagBufferResult) { + tagBuffer = tagBufferResult; + return signingCallback(tagBuffer); + }).then(function (_ref) { + var code = _ref.code, + signedData = _ref.signedData; + + switch (code) { + case NodeGit.Error.CODE.OK: + { + var normalizedEnding = signedData.endsWith("\n") ? "" : "\n"; + var signedTagString = tagBuffer + signedData + normalizedEnding; + return Tag.createFromBuffer(repo, signedTagString, force); + } + case NodeGit.Error.CODE.PASSTHROUGH: + return Tag.create(repo, tagName, target, tagger, message, force); + default: + { + var error = new Error("Tag.createWithSignature threw with error code " + code); + error.errno = code; + throw error; + } + } + }); +}; + +/** + * Retrieves the signature of an annotated tag + * @async + * @param {String} signatureType + * @return {String|null} + */ +Tag.prototype.extractSignature = function () { + var signatureType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "gpgsig"; + + var id = this.id(); + var repo = this.repo; + var signatureRegexes = signatureRegexesBySignatureType[signatureType]; + if (!signatureRegexes) { + throw new Error("Unsupported signature type"); + } + + return repo.odb().then(function (odb) { + return odb.read(id); + }).then(function (odbObject) { + var odbData = odbObject.toString(); + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = signatureRegexes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var regex = _step.value; + + var matchResult = odbData.match(regex); + + if (matchResult !== null) { + return matchResult[0]; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + throw new Error("this tag is not signed"); + }); +}; \ No newline at end of file diff --git a/dist/tree.js b/dist/tree.js new file mode 100644 index 000000000..c2dc363e1 --- /dev/null +++ b/dist/tree.js @@ -0,0 +1,190 @@ +"use strict"; + +var path = require("path"); +var events = require("events"); +var NodeGit = require("../"); +var Diff = NodeGit.Diff; +var LookupWrapper = NodeGit.Utils.lookupWrapper; +var Tree = NodeGit.Tree; +var Treebuilder = NodeGit.Treebuilder; + +/** +* Retrieves the tree pointed to by the oid +* @async +* @param {Repository} repo The repo that the tree lives in +* @param {String|Oid|Tree} id The tree to lookup +* @param {Function} callback +* @return {Tree} +*/ +Tree.lookup = LookupWrapper(Tree); + +/** + * Make builder. This is helpful for modifying trees. + * @return {Treebuilder} + */ +Tree.prototype.builder = function () { + var builder = Treebuilder.create(this); + + builder.root = builder; + builder.repo = this.repo; + + return builder; +}; + +/** + * Diff two trees + * @async + * @param {Tree} tree to diff against + * @param {Function} callback + * @return {Diff} + */ +Tree.prototype.diff = function (tree, callback) { + return this.diffWithOptions(tree, null, callback); +}; + +/** + * Diff two trees with options + * @async + * @param {Tree} tree to diff against + * @param {Object} options + * @param {Function} callback + * @return {Diff} + */ +Tree.prototype.diffWithOptions = function (tree, options, callback) { + return Diff.treeToTree(this.repo, tree, this, options).then(function (diff) { + if (typeof callback === "function") { + callback(null, diff); + } + + return diff; + }, callback); +}; + +/** + * Return an array of the entries in this tree (excluding its children). + * @return {Array} an array of TreeEntrys + */ +Tree.prototype.entries = function () { + var size = this.entryCount(); + var result = []; + + for (var i = 0; i < size; i++) { + result.push(this.entryByIndex(i)); + } + + return result; +}; + +/** + * Get an entry at the ith position. + * + * @param {Number} i + * @return {TreeEntry} + */ +Tree.prototype.entryByIndex = function (i) { + var entry = this._entryByIndex(i); + entry.parent = this; + return entry; +}; + +/** + * Get an entry by name; if the tree is a directory, the name is the filename. + * + * @param {String} name + * @return {TreeEntry} + */ +Tree.prototype.entryByName = function (name) { + var entry = this._entryByName(name); + entry.parent = this; + return entry; +}; + +/** + * Get an entry at a path. Unlike by name, this takes a fully + * qualified path, like `/foo/bar/baz.javascript` + * @async + * @param {String} filePath + * @return {TreeEntry} + */ +Tree.prototype.getEntry = function (filePath, callback) { + var tree = this; + + return this.entryByPath(filePath).then(function (entry) { + entry.parent = tree; + entry.dirtoparent = path.dirname(filePath); + + if (typeof callback === "function") { + callback(null, entry); + } + + return entry; + }); +}; + +/** + * Return the path of this tree, like `/lib/foo/bar` + * @return {String} + */ +Tree.prototype.path = function (blobsOnly) { + return this.entry ? this.entry.path() : ""; +}; + +/** + * Recursively walk the tree in breadth-first order. Fires an event for each + * entry. + * + * @fires EventEmitter#entry Tree + * @fires EventEmitter#end Array + * @fires EventEmitter#error Error + * + * @param {Boolean} [blobsOnly = true] True to emit only blob & blob executable + * entries. + * + * @return {EventEmitter} + */ +Tree.prototype.walk = function (blobsOnly) { + blobsOnly = typeof blobsOnly === "boolean" ? blobsOnly : true; + + var self = this; + var event = new events.EventEmitter(); + + var total = 1; + var entries = new Set(); + var finalEntires = []; + + // This looks like a DFS, but it is a BFS because of implicit queueing in + // the recursive call to `entry.getTree(bfs)` + function bfs(error, tree) { + total--; + + if (error) { + return event.emit("error", error); + } + + tree.entries().forEach(function (entry, entryIndex) { + if (!blobsOnly || entry.isFile() && !entries.has(entry)) { + event.emit("entry", entry); + entries.add(entry); + + // Node 0.12 doesn't support either [v for (v of entries)] nor + // Array.from so we'll just maintain our own list. + finalEntires.push(entry); + } + + if (entry.isTree()) { + total++; + entry.getTree(bfs); + } + }); + + if (total === 0) { + event.emit("end", finalEntires); + } + } + + event.start = function () { + bfs(null, self); + }; + + return event; +}; \ No newline at end of file diff --git a/dist/tree_entry.js b/dist/tree_entry.js new file mode 100644 index 000000000..5a42cfc09 --- /dev/null +++ b/dist/tree_entry.js @@ -0,0 +1,111 @@ +"use strict"; + +var path = require("path").posix; +var NodeGit = require("../"); +var TreeEntry = NodeGit.TreeEntry; + +/** + * Retrieve the blob for this entry. Make sure to call `isBlob` first! + * @async + * @return {Blob} + */ +TreeEntry.prototype.getBlob = function (callback) { + return this.parent.repo.getBlob(this.id()).then(function (blob) { + if (typeof callback === "function") { + callback(null, blob); + } + + return blob; + }, callback); +}; + +/** + * Retrieve the tree for this entry. Make sure to call `isTree` first! + * @async + * @return {Tree} + */ +TreeEntry.prototype.getTree = function (callback) { + var entry = this; + + return this.parent.repo.getTree(this.id()).then(function (tree) { + tree.entry = entry; + + if (typeof callback === "function") { + callback(null, tree); + } + + return tree; + }, callback); +}; + +/** + * Is this TreeEntry a blob? Alias for `isFile` + * @return {Boolean} + */ +TreeEntry.prototype.isBlob = function () { + return this.isFile(); +}; + +/** + * Is this TreeEntry a directory? Alias for `isTree` + * @return {Boolean} + */ +TreeEntry.prototype.isDirectory = function () { + return this.isTree(); +}; + +/** + * Is this TreeEntry a blob? (i.e., a file) + * @return {Boolean} + */ +TreeEntry.prototype.isFile = function () { + return this.filemode() === TreeEntry.FILEMODE.BLOB || this.filemode() === TreeEntry.FILEMODE.EXECUTABLE; +}; + +/** + * Is this TreeEntry a submodule? + * @return {Boolean} + */ +TreeEntry.prototype.isSubmodule = function () { + return this.filemode() === TreeEntry.FILEMODE.COMMIT; +}; + +/** + * Is this TreeEntry a tree? (i.e., a directory) + * @return {Boolean} + */ +TreeEntry.prototype.isTree = function () { + return this.filemode() === TreeEntry.FILEMODE.TREE; +}; + +/** + * Retrieve the SHA for this TreeEntry. Alias for `sha` + * @return {String} + */ +TreeEntry.prototype.oid = function () { + return this.sha(); +}; + +/** + * Returns the path for this entry. + * @return {String} + */ +TreeEntry.prototype.path = function (callback) { + var dirtoparent = this.dirtoparent || ""; + return path.join(this.parent.path(), dirtoparent, this.name()); +}; + +/** + * Retrieve the SHA for this TreeEntry. + * @return {String} + */ +TreeEntry.prototype.sha = function () { + return this.id().toString(); +}; + +/** + * Alias for `path` + */ +TreeEntry.prototype.toString = function () { + return this.path(); +}; \ No newline at end of file diff --git a/dist/utils/lookup_wrapper.js b/dist/utils/lookup_wrapper.js new file mode 100644 index 000000000..5bffb3540 --- /dev/null +++ b/dist/utils/lookup_wrapper.js @@ -0,0 +1,41 @@ +"use strict"; + +var NodeGit = require("../../"); + +/** +* Wraps a method so that you can pass in either a string, OID or the object +* itself and you will always get back a promise that resolves to the object. +* @param {Object} objectType The object type that you're expecting to receive. +* @param {Function} lookupFunction The function to do the lookup for the +* object. Defaults to `objectType.lookup`. +* @return {Function} +*/ +function lookupWrapper(objectType, lookupFunction) { + lookupFunction = lookupFunction || objectType.lookup; + + return function (repo, id, callback) { + if (id instanceof objectType) { + return Promise.resolve(id).then(function (obj) { + obj.repo = repo; + + if (typeof callback === "function") { + callback(null, obj); + } + + return obj; + }, callback); + } + + return lookupFunction(repo, id).then(function (obj) { + obj.repo = repo; + + if (typeof callback === "function") { + callback(null, obj); + } + + return obj; + }, callback); + }; +} + +NodeGit.Utils.lookupWrapper = lookupWrapper; \ No newline at end of file diff --git a/dist/utils/normalize_fetch_options.js b/dist/utils/normalize_fetch_options.js new file mode 100644 index 000000000..8a7fe658d --- /dev/null +++ b/dist/utils/normalize_fetch_options.js @@ -0,0 +1,43 @@ +"use strict"; + +var NodeGit = require("../../"); +var normalizeOptions = NodeGit.Utils.normalizeOptions; +var shallowClone = NodeGit.Utils.shallowClone; + +/** + * Normalize an object to match a struct. + * + * @param {String, Object} oid - The oid string or instance. + * @return {Object} An Oid instance. + */ +function normalizeFetchOptions(options) { + if (options instanceof NodeGit.FetchOptions) { + return options; + } + + var callbacks; + var proxyOpts; + + if (options) { + options = shallowClone(options); + callbacks = options.callbacks; + proxyOpts = options.proxyOpts; + delete options.callbacks; + delete options.proxyOpts; + } else { + options = {}; + } + + options = normalizeOptions(options, NodeGit.FetchOptions); + + if (callbacks) { + options.callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks); + } + + if (proxyOpts) { + options.proxyOpts = normalizeOptions(proxyOpts, NodeGit.ProxyOptions); + } + return options; +} + +NodeGit.Utils.normalizeFetchOptions = normalizeFetchOptions; \ No newline at end of file diff --git a/dist/utils/normalize_options.js b/dist/utils/normalize_options.js new file mode 100644 index 000000000..44568bbe1 --- /dev/null +++ b/dist/utils/normalize_options.js @@ -0,0 +1,31 @@ +"use strict"; + +var NodeGit = require("../../"); + +/** + * Normalize an object to match a struct. + * + * @param {String, Object} oid - The oid string or instance. + * @return {Object} An Oid instance. + */ +function normalizeOptions(options, Ctor) { + if (!options) { + return null; + } + + if (options instanceof Ctor) { + return options; + } + + var instance = new Ctor(); + + Object.keys(options).forEach(function (key) { + if (typeof options[key] !== "undefined") { + instance[key] = options[key]; + } + }); + + return instance; +} + +NodeGit.Utils.normalizeOptions = normalizeOptions; \ No newline at end of file diff --git a/dist/utils/shallow_clone.js b/dist/utils/shallow_clone.js new file mode 100644 index 000000000..4b7850990 --- /dev/null +++ b/dist/utils/shallow_clone.js @@ -0,0 +1,16 @@ +"use strict"; + +var NodeGit = require("../../"); + +function shallowClone() { + var merges = Array.prototype.slice.call(arguments); + + return merges.reduce(function (obj, merge) { + return Object.keys(merge).reduce(function (obj, key) { + obj[key] = merge[key]; + return obj; + }, obj); + }, {}); +} + +NodeGit.Utils.shallowClone = shallowClone; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b6b80976a..81ba82b1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -101,13 +101,15 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true + "dev": true, + "optional": true }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true + "dev": true, + "optional": true }, "array-unique": { "version": "0.2.1", @@ -138,7 +140,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true + "dev": true, + "optional": true }, "async": { "version": "1.5.2", @@ -162,7 +165,8 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true + "dev": true, + "optional": true }, "aws-sdk": { "version": "2.326.0", @@ -791,6 +795,7 @@ "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, + "optional": true, "requires": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -806,6 +811,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -815,6 +821,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -824,6 +831,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -833,6 +841,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -843,13 +852,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -965,6 +976,7 @@ "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, + "optional": true, "requires": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -981,7 +993,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -1073,6 +1086,7 @@ "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, + "optional": true, "requires": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -1085,6 +1099,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -1093,7 +1108,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -1201,6 +1217,7 @@ "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, + "optional": true, "requires": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -1237,7 +1254,8 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", @@ -1294,7 +1312,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true + "dev": true, + "optional": true }, "core-js": { "version": "2.5.7", @@ -1409,7 +1428,8 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true + "dev": true, + "optional": true }, "deep-extend": { "version": "0.6.0", @@ -1436,6 +1456,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, + "optional": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -1446,6 +1467,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -1455,6 +1477,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -1464,6 +1487,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -1474,13 +1498,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -1697,6 +1723,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, + "optional": true, "requires": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -1707,6 +1734,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "optional": true, "requires": { "is-plain-object": "^2.0.4" } @@ -1809,7 +1837,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "dev": true, + "optional": true }, "for-own": { "version": "0.1.5", @@ -1847,6 +1876,7 @@ "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, + "optional": true, "requires": { "map-cache": "^0.2.2" } @@ -1925,7 +1955,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -1946,12 +1977,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1966,17 +1999,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2093,7 +2129,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2105,6 +2142,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2119,6 +2157,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2126,12 +2165,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2150,6 +2191,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2237,7 +2279,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2249,6 +2292,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2334,7 +2378,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2370,6 +2415,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2389,6 +2435,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2432,12 +2479,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -2466,7 +2515,8 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true + "dev": true, + "optional": true }, "getpass": { "version": "0.1.7", @@ -2505,6 +2555,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, + "optional": true, "requires": { "is-glob": "^2.0.0" } @@ -2636,6 +2687,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, + "optional": true, "requires": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -2646,7 +2698,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -2655,6 +2708,7 @@ "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, + "optional": true, "requires": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -2665,6 +2719,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -2674,6 +2729,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -2685,6 +2741,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -2838,6 +2895,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -2863,6 +2921,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -2872,6 +2931,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -2882,7 +2942,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true + "dev": true, + "optional": true } } }, @@ -2907,13 +2968,15 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true + "dev": true, + "optional": true }, "is-extglob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true + "dev": true, + "optional": true }, "is-finite": { "version": "1.0.2", @@ -2937,6 +3000,7 @@ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, + "optional": true, "requires": { "is-extglob": "^1.0.0" } @@ -2962,6 +3026,7 @@ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, + "optional": true, "requires": { "isobject": "^3.0.1" }, @@ -2970,7 +3035,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -3270,6 +3336,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -3361,13 +3428,15 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true + "dev": true, + "optional": true }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, + "optional": true, "requires": { "object-visit": "^1.0.0" } @@ -3448,6 +3517,7 @@ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, + "optional": true, "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -3458,6 +3528,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "optional": true, "requires": { "is-plain-object": "^2.0.4" } @@ -3761,6 +3832,7 @@ "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, + "optional": true, "requires": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -3772,6 +3844,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -3789,6 +3862,7 @@ "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, + "optional": true, "requires": { "isobject": "^3.0.0" }, @@ -3797,7 +3871,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -3829,6 +3904,7 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, + "optional": true, "requires": { "isobject": "^3.0.1" }, @@ -3837,7 +3913,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -3955,7 +4032,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true + "dev": true, + "optional": true }, "path-dirname": { "version": "1.0.2", @@ -4080,11 +4158,12 @@ "optional": true }, "promisify-node": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.3.0.tgz", - "integrity": "sha1-tLVaz5D6p9K4uQyjlomQhsAwYM8=", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.5.0.tgz", + "integrity": "sha512-GR2E4qgCoKFTprhULqP2OP3bl8kHo16XtnqtkHH6be7tPW1yL6rXd15nl3oV2sLTFv1+j6tqoF69VVpFtJ/j+A==", "requires": { - "nodegit-promise": "~4.0.0" + "nodegit-promise": "^4.0.0", + "object-assign": "^4.1.1" } }, "proto-list": { @@ -4223,7 +4302,8 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true + "dev": true, + "optional": true }, "braces": { "version": "2.3.2", @@ -4486,7 +4566,8 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true }, "micromatch": { "version": "3.1.10", @@ -4550,6 +4631,7 @@ "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, + "optional": true, "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" @@ -4620,13 +4702,15 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true + "dev": true, + "optional": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "dev": true, + "optional": true }, "repeating": { "version": "2.0.1", @@ -4724,13 +4808,15 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true + "dev": true, + "optional": true }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true + "dev": true, + "optional": true }, "rimraf": { "version": "2.6.2", @@ -4750,6 +4836,7 @@ "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, + "optional": true, "requires": { "ret": "~0.1.10" } @@ -4780,6 +4867,7 @@ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, + "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -4792,6 +4880,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -4820,6 +4909,7 @@ "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, + "optional": true, "requires": { "base": "^0.11.1", "debug": "^2.2.0", @@ -4836,6 +4926,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -4845,6 +4936,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -4916,7 +5008,8 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -4941,6 +5034,7 @@ "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, + "optional": true, "requires": { "atob": "^2.1.1", "decode-uri-component": "^0.2.0", @@ -4962,7 +5056,8 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true + "dev": true, + "optional": true }, "split": { "version": "1.0.1", @@ -4979,6 +5074,7 @@ "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, + "optional": true, "requires": { "extend-shallow": "^3.0.0" } @@ -5017,6 +5113,7 @@ "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, + "optional": true, "requires": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -5027,6 +5124,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -5206,6 +5304,7 @@ "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -5215,6 +5314,7 @@ "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, + "optional": true, "requires": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -5343,6 +5443,7 @@ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, + "optional": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -5370,6 +5471,7 @@ "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, + "optional": true, "requires": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -5380,6 +5482,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, + "optional": true, "requires": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -5391,6 +5494,7 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, + "optional": true, "requires": { "isarray": "1.0.0" } @@ -5401,13 +5505,15 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true + "dev": true, + "optional": true }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -5415,7 +5521,8 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true + "dev": true, + "optional": true }, "url": { "version": "0.10.3", @@ -5439,7 +5546,8 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true + "dev": true, + "optional": true }, "user-home": { "version": "1.1.1", diff --git a/package.json b/package.json index 50f226a0d..0410d7c04 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "nan": "^2.14.0", "node-gyp": "^4.0.0", "node-pre-gyp": "^0.13.0", - "promisify-node": "~0.3.0", + "promisify-node": "~0.5.0", "ramda": "^0.25.0", "request-promise-native": "^1.0.5", "tar-fs": "^1.16.3"