| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,18 @@ | |||
| 1 | 1 | { | |
| 2 | + "evil": true, | ||
| 3 | + "boss": true, | ||
| 4 | + "immed": false, | ||
| 5 | + "eqnull": true, | ||
| 6 | + "maxlen": 80, | ||
| 2 | 7 | "node": true, | |
| 3 | - "proto": true | ||
| 8 | + "curly": true, | ||
| 9 | + "quotmark": "double", | ||
| 10 | + "trailing": true, | ||
| 11 | + "unused": "vars", | ||
| 12 | + "undef": true, | ||
| 13 | + "validthis": true, | ||
| 14 | + "globals": { | ||
| 15 | + "global": true, | ||
| 16 | + "define": true | ||
| 17 | + } | ||
| 4 | 18 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,13 @@ | |||
| 34 | 34 | } | |
| 35 | 35 | }, | |
| 36 | 36 | ||
| 37 | + "git_blob_is_binary": { | ||
| 38 | + "ignore": false, | ||
| 39 | + "args": [ | ||
| 40 | + { "isReturn": false, "isSelf": true } | ||
| 41 | + ] | ||
| 42 | + }, | ||
| 43 | + | ||
| 37 | 44 | "git_blob_create_frombuffer": { | |
| 38 | 45 | "ignore": false, | |
| 39 | 46 | "isAsync": true, | |
@@ -671,7 +678,7 @@ | |||
| 671 | 678 | "ignore": false, | |
| 672 | 679 | "isAsync": true, | |
| 673 | 680 | "isConstructorMethod": true, | |
| 674 | - "args": [{ "isReturn": true }, { "isSelf": true }], | ||
| 681 | + "args": [{ "isReturn": true }], | ||
| 675 | 682 | "return": { | |
| 676 | 683 | "isErrorCode": true | |
| 677 | 684 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,31 +1,32 @@ | |||
| 1 | - var git = require('../'); | ||
| 2 | - var TreeEntry = git.TreeEntry; | ||
| 3 | - var Blob = git.Blob; | ||
| 1 | + var NodeGit = require("../"); | ||
| 2 | + var TreeEntry = require("./tree_entry"); | ||
| 3 | + var Blob = NodeGit.Blob; | ||
| 4 | 4 | ||
| 5 | - // Assign deprecated methods. | ||
| 6 | - Object.defineProperty(Blob.prototype, "size", { | ||
| 7 | - value: Blob.prototype.rawsize, | ||
| 8 | - enumerable: false | ||
| 9 | - }); | ||
| 5 | + var FileMode = TreeEntry.FileMode; | ||
| 10 | 6 | ||
| 11 | 7 | /** | |
| 12 | - * Retrieve the content of the blob. | ||
| 13 | - * @return {Buffer} content | ||
| 8 | + * Retrieve the content of the Blob. | ||
| 9 | + * | ||
| 10 | + * @return {Buffer} Contents. | ||
| 14 | 11 | */ | |
| 15 | 12 | Blob.prototype.content = function() { | |
| 16 | 13 | return this.rawcontent().toBuffer(this.rawsize()); | |
| 17 | 14 | }; | |
| 18 | 15 | ||
| 19 | 16 | /** | |
| 20 | - * Retrieve the blob's content as String. | ||
| 17 | + * Retrieve the Blob's content as String. | ||
| 18 | + * | ||
| 19 | + * @return {string} Contents. | ||
| 21 | 20 | */ | |
| 22 | 21 | Blob.prototype.toString = function() { | |
| 23 | 22 | return this.content().toString(); | |
| 24 | 23 | }; | |
| 25 | 24 | ||
| 26 | 25 | /** | |
| 27 | - * Retrieve the blob's type. | ||
| 26 | + * Retrieve the Blob's type. | ||
| 27 | + * | ||
| 28 | + * @return {number} The filemode. | ||
| 28 | 29 | */ | |
| 29 | 30 | Blob.prototype.filemode = function() { | |
| 30 | - return this.isBinary() ? TreeEntry.FileMode.Executable : TreeEntry.FileMode.Blob; | ||
| 31 | + return this.isBinary() ? FileMode.Executable : FileMode.Blob; | ||
| 31 | 32 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,35 +1,14 @@ | |||
| 1 | 1 | var Promise = require("promise"); | |
| 2 | - var git = require('../'); | ||
| 2 | + var git = require("../"); | ||
| 3 | 3 | var Commit = git.Commit; | |
| 4 | - var Oid = git.Oid; | ||
| 5 | - var Revwalk = git.Revwalk; | ||
| 6 | - var events = require('events'); | ||
| 7 | - var Tree = require("./tree"); | ||
| 8 | - | ||
| 9 | - // Backwards compatibility. | ||
| 10 | - Object.defineProperties(Commit.prototype, { | ||
| 11 | - "oid": { | ||
| 12 | - value: Commit.prototype.id, | ||
| 13 | - enumerable: false | ||
| 14 | - }, | ||
| 15 | - | ||
| 16 | - "offset": { | ||
| 17 | - value: Commit.prototype.timeOffset, | ||
| 18 | - enumerable: false | ||
| 19 | - }, | ||
| 20 | - | ||
| 21 | - "parentCount": { | ||
| 22 | - value: Commit.prototype.parentcount, | ||
| 23 | - enumerable: false | ||
| 24 | - } | ||
| 25 | - }); | ||
| 4 | + var events = require("events"); | ||
| 26 | 5 | ||
| 27 | 6 | /** | |
| 28 | 7 | * Retrieve the SHA. | |
| 29 | 8 | * @return {String} | |
| 30 | 9 | */ | |
| 31 | 10 | Commit.prototype.sha = function() { | |
| 32 | - return this.oid().toString(); | ||
| 11 | + return this.id().toString(); | ||
| 33 | 12 | }; | |
| 34 | 13 | ||
| 35 | 14 | /** | |
@@ -53,7 +32,7 @@ Commit.prototype.date = function() { | |||
| 53 | 32 | * @return {Tree} | |
| 54 | 33 | */ | |
| 55 | 34 | Commit.prototype.getTree = function(callback) { | |
| 56 | - this.repo.getTree(this.treeId(), callback); | ||
| 35 | + return this.repo.getTree(this.treeId(), callback); | ||
| 57 | 36 | }; | |
| 58 | 37 | ||
| 59 | 38 | /** | |
@@ -65,18 +44,22 @@ Commit.prototype.getTree = function(callback) { | |||
| 65 | 44 | * @return {TreeEntry} | |
| 66 | 45 | */ | |
| 67 | 46 | Commit.prototype.getEntry = function(path, callback) { | |
| 68 | - this.getTree(function(error, tree) { | ||
| 69 | - if (error) return callback(error); | ||
| 47 | + return this.getTree().then(function(tree) { | ||
| 48 | + return tree.getEntry(path).then(function(entry) { | ||
| 49 | + if (callback) { | ||
| 50 | + callback(entry); | ||
| 51 | + } | ||
| 70 | 52 | ||
| 71 | - tree.getEntry(path, callback); | ||
| 72 | - }); | ||
| 53 | + return entry; | ||
| 54 | + }); | ||
| 55 | + }, callback); | ||
| 73 | 56 | }; | |
| 74 | 57 | ||
| 75 | 58 | /** | |
| 76 | 59 | * Walk the history from this commit backwards. | |
| 77 | - * An EventEmitter is returned that will emit a 'commit' event for each | ||
| 78 | - * commit in the history, and one 'end' event when the walk is completed. | ||
| 79 | - * Don't forget to call `start()` on the returned event. | ||
| 60 | + * An EventEmitter is returned that will emit a "commit" event for each | ||
| 61 | + * commit in the history, and one "end" event when the walk is completed. | ||
| 62 | + * Don"t forget to call `start()` on the returned event. | ||
| 80 | 63 | * | |
| 81 | 64 | * @fires Commit#commit | |
| 82 | 65 | * @fires Commit#end | |
@@ -85,7 +68,7 @@ Commit.prototype.getEntry = function(path, callback) { | |||
| 85 | 68 | */ | |
| 86 | 69 | Commit.prototype.history = function() { | |
| 87 | 70 | var event = new events.EventEmitter(); | |
| 88 | - var oid = this.oid(); | ||
| 71 | + var oid = this.id(); | ||
| 89 | 72 | var revwalk = this.repo.createRevWalk(); | |
| 90 | 73 | ||
| 91 | 74 | revwalk.sorting.apply(revwalk, arguments); | |
@@ -94,14 +77,16 @@ Commit.prototype.history = function() { | |||
| 94 | 77 | ||
| 95 | 78 | event.start = function() { | |
| 96 | 79 | revwalk.walk(oid, function commitRevWalk(error, commit) { | |
| 97 | - if (error) return event.emit('error', error); | ||
| 80 | + if (error) { | ||
| 81 | + return event.emit("error", error); | ||
| 82 | + } | ||
| 98 | 83 | ||
| 99 | 84 | if (!commit) { | |
| 100 | - event.emit('end', commits); | ||
| 85 | + event.emit("end", commits); | ||
| 101 | 86 | return; | |
| 102 | 87 | } | |
| 103 | 88 | ||
| 104 | - event.emit('commit', commit); | ||
| 89 | + event.emit("commit", commit); | ||
| 105 | 90 | commits.push(commit); | |
| 106 | 91 | }); | |
| 107 | 92 | }; | |
@@ -110,14 +95,13 @@ Commit.prototype.history = function() { | |||
| 110 | 95 | }; | |
| 111 | 96 | ||
| 112 | 97 | /** | |
| 113 | - * Retrieve the commit's parents -- as commit objects. | ||
| 98 | + * Retrieve the commit"s parents -- as commit objects. | ||
| 114 | 99 | * | |
| 115 | 100 | * @param {number} limit - Optional amount of parents to return. | |
| 116 | 101 | * @param {Function} callback | |
| 117 | 102 | * @return {[Commit]} array of commits | |
| 118 | 103 | */ | |
| 119 | 104 | Commit.prototype.getParents = function(limit, callback) { | |
| 120 | - var commit = this; | ||
| 121 | 105 | var parents = []; | |
| 122 | 106 | var i = 0; | |
| 123 | 107 | ||
@@ -127,7 +111,7 @@ Commit.prototype.getParents = function(limit, callback) { | |||
| 127 | 111 | } | |
| 128 | 112 | ||
| 129 | 113 | // If no limit was set, default to the maximum parents. | |
| 130 | - limit = typeof limit === "number" ? limit : this.parentCount(); | ||
| 114 | + limit = typeof limit === "number" ? limit : this.parentcount(); | ||
| 131 | 115 | ||
| 132 | 116 | function processParents(commit, callback) { | |
| 133 | 117 | var oid = commit.parentId(i); | |
@@ -163,14 +147,14 @@ Commit.prototype.getParents = function(limit, callback) { | |||
| 163 | 147 | }; | |
| 164 | 148 | ||
| 165 | 149 | /** | |
| 166 | - * Retrieve the commit's parent shas. | ||
| 150 | + * Retrieve the commit"s parent shas. | ||
| 167 | 151 | * | |
| 168 | 152 | * @param {Function} callback | |
| 169 | 153 | * @return {[Oid]} array of oids | |
| 170 | 154 | */ | |
| 171 | 155 | Commit.prototype.parents = function() { | |
| 172 | 156 | var result = []; | |
| 173 | - for (var i = 0; i < this.parentCount(); i++) { | ||
| 157 | + for (var i = 0; i < this.parentcount(); i++) { | ||
| 174 | 158 | result.push(this.parentId(i)); | |
| 175 | 159 | } | |
| 176 | 160 | return result; | |
@@ -184,30 +168,23 @@ Commit.prototype.parents = function() { | |||
| 184 | 168 | * @return {[Diff]} an array of diffs | |
| 185 | 169 | */ | |
| 186 | 170 | Commit.prototype.getDiff = function(callback) { | |
| 187 | - var self = this; | ||
| 188 | - self.getParents(function commitParents(error, parents) { | ||
| 189 | - if (error) return callback(error); | ||
| 190 | - | ||
| 191 | - var parentDiffs = []; | ||
| 192 | - parents.forEach(function commitEachParent(parent) { | ||
| 193 | - parent.getTree(function(error, parentTree) { | ||
| 194 | - if (error) return callback(error); | ||
| 195 | - | ||
| 196 | - self.getTree(function(error, thisTree) { | ||
| 197 | - if (error) return callback(error); | ||
| 198 | - | ||
| 199 | - parentTree.diff(thisTree, function walkDiff(error, diff) { | ||
| 200 | - if (error) return callback(error); | ||
| 201 | - | ||
| 202 | - parentDiffs.push(diff); | ||
| 203 | - if (parentDiffs.length === parents.length) { | ||
| 204 | - callback(null, parentDiffs); | ||
| 205 | - } | ||
| 206 | - }); | ||
| 171 | + var commit = this; | ||
| 172 | + | ||
| 173 | + return commit.getParents().then(function(parents) { | ||
| 174 | + return parents.map(function(parent) { | ||
| 175 | + return parent.getTree(function(parentTree) { | ||
| 176 | + return commit.getTree(function(thisTree) { | ||
| 177 | + return parentTree.diff(thisTree); | ||
| 207 | 178 | }); | |
| 208 | 179 | }); | |
| 209 | 180 | }); | |
| 210 | - }); | ||
| 181 | + }).then(function(parentDiffs) { | ||
| 182 | + if (callback) { | ||
| 183 | + callback(null, parentDiffs); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + return parentDiffs; | ||
| 187 | + }, callback); | ||
| 211 | 188 | }; | |
| 212 | 189 | ||
| 213 | 190 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,13 +16,6 @@ Object.defineProperty(git, "Repo", { | |||
| 16 | 16 | enumerable: false | |
| 17 | 17 | }); | |
| 18 | 18 | ||
| 19 | - var oldGetReference = Reference.lookup, | ||
| 20 | - oldGetTree = Tree.lookup, | ||
| 21 | - oldGetTag = Repo.prototype.getTag, | ||
| 22 | - oldCreateRevwalk = Revwalk.createRevwalk, | ||
| 23 | - oldCreateCommit = Commit.createCommit, | ||
| 24 | - oldCreateBlobFromBuffer = Blob.createFrombuffer; | ||
| 25 | - | ||
| 26 | 19 | /** | |
| 27 | 20 | * Look up a branch's most recent commit. | |
| 28 | 21 | * | |
@@ -128,15 +121,21 @@ Repo.prototype.getBlob = function(oid, callback) { | |||
| 128 | 121 | * @return {Tree} | |
| 129 | 122 | */ | |
| 130 | 123 | Repo.prototype.getTree = function(oid, callback) { | |
| 131 | - var self = this; | ||
| 132 | - oldGetTree.call(this, oid, function(error, tree) { | ||
| 133 | - if (error) return callback(error); | ||
| 134 | - tree.repo = self; | ||
| 135 | - callback(null, tree); | ||
| 136 | - }); | ||
| 124 | + oid = normalizeOid(oid); | ||
| 125 | + | ||
| 126 | + var repository = this; | ||
| 127 | + | ||
| 128 | + | ||
| 129 | + return Tree.lookup(repository, oid).then(function(tree) { | ||
| 130 | + tree.repo = repository; | ||
| 131 | + | ||
| 132 | + if (callback) { | ||
| 133 | + callback(null, tree); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + return tree; | ||
| 137 | + }, callback); | ||
| 137 | 138 | }; | |
| 138 | - util.normalizeOid(Repo.prototype, 'getTree'); | ||
| 139 | - util.makeSafe(Repo.prototype, 'getTree'); | ||
| 140 | 139 | ||
| 141 | 140 | /** | |
| 142 | 141 | * Retrieve the tag represented by the oid. | |
@@ -146,11 +145,20 @@ util.makeSafe(Repo.prototype, 'getTree'); | |||
| 146 | 145 | * @return {Tag} | |
| 147 | 146 | */ | |
| 148 | 147 | Repo.prototype.getTag = function(oid, callback) { | |
| 149 | - var self = this; | ||
| 150 | - oldGetTag.call(this, oid, callback); | ||
| 148 | + oid = normalizeOid(oid); | ||
| 149 | + | ||
| 150 | + var repository = this; | ||
| 151 | + | ||
| 152 | + return Reference.lookup(repository, oid).then(function(reference) { | ||
| 153 | + reference.repo = repository; | ||
| 154 | + | ||
| 155 | + if (callback) { | ||
| 156 | + callback(null, reference); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + return reference; | ||
| 160 | + }, callback); | ||
| 151 | 161 | }; | |
| 152 | - util.normalizeOid(Repo.prototype, 'getTag'); | ||
| 153 | - util.makeSafe(Repo.prototype, 'getTag'); | ||
| 154 | 162 | ||
| 155 | 163 | /** | |
| 156 | 164 | * Instantiate a new revision walker for browsing the Repo's history. | |
@@ -161,7 +169,7 @@ util.makeSafe(Repo.prototype, 'getTag'); | |||
| 161 | 169 | * @return {RevWalk} | |
| 162 | 170 | */ | |
| 163 | 171 | Repo.prototype.createRevWalk = function() { | |
| 164 | - var revWalk = oldCreateRevwalk(this); | ||
| 172 | + var revWalk = Revwalk.createRevwalk(this); | ||
| 165 | 173 | revWalk.repo = this; | |
| 166 | 174 | return revWalk; | |
| 167 | 175 | }; | |
@@ -190,7 +198,7 @@ Repo.prototype.getMaster = function(callback) { | |||
| 190 | 198 | */ | |
| 191 | 199 | Repo.prototype.createCommit = function(updateRef, author, committer, message, tree, parents, callback) { | |
| 192 | 200 | if (tree instanceof Tree) { | |
| 193 | - oldCreateCommit.call( | ||
| 201 | + Commit.createCommit.call( | ||
| 194 | 202 | this, | |
| 195 | 203 | updateRef, | |
| 196 | 204 | author, | |
@@ -204,7 +212,7 @@ Repo.prototype.createCommit = function(updateRef, author, committer, message, tr | |||
| 204 | 212 | var self = this; | |
| 205 | 213 | this.getTree(tree, function(error, tree) { | |
| 206 | 214 | if (error) return callback(error); | |
| 207 | - oldCreateCommit.call( | ||
| 215 | + Commit.createCommit.call( | ||
| 208 | 216 | self, | |
| 209 | 217 | updateRef, | |
| 210 | 218 | author, | |
@@ -226,7 +234,7 @@ Repo.prototype.createCommit = function(updateRef, author, committer, message, tr | |||
| 226 | 234 | * @return {Blob} | |
| 227 | 235 | */ | |
| 228 | 236 | Repo.prototype.createBlobFromBuffer = function(buffer, callback) { | |
| 229 | - oldCreateBlobFromBuffer.call(this, buffer, buffer.length, callback); | ||
| 237 | + Blob.createFrombuffer.call(this, buffer, buffer.length, callback); | ||
| 230 | 238 | }; | |
| 231 | 239 | ||
| 232 | 240 | /** | |
| Back | FazBrowse Home | New Git URL |
0 commit comments