| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | 1 | - rename all async methods getXXX | |
| 2 | - - reorder functions so the raw api is oo-like | ||
| 2 | + - audit all ** methods so that all finds go through the repo in js land so that the .repo pointer is set. | ||
| 3 | 3 | - rename files remove .h | |
| 4 | + - Cleanup diff api | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ git.repo('.git', function(error, repository) { | |||
| 7 | 7 | if (error) throw error; | |
| 8 | 8 | ||
| 9 | 9 | // Use the master branch (a branch is the HEAD commit) | |
| 10 | - repository.branch('master', function(error, branch) { | ||
| 10 | + repository.getBranch('master', function(error, branch) { | ||
| 11 | 11 | if (error) throw error; | |
| 12 | 12 | ||
| 13 | 13 | // History returns an event, and begins walking the history | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ git.repo('.git', function(error, repository) { | |||
| 6 | 6 | if (error) throw error; | |
| 7 | 7 | ||
| 8 | 8 | // Use the master branch. | |
| 9 | - repository.branch('master', function(error, branch) { | ||
| 9 | + repository.getBranch('master', function(error, branch) { | ||
| 10 | 10 | if (error) throw error; | |
| 11 | 11 | ||
| 12 | 12 | // Iterate over the revision history. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,19 +38,6 @@ class GitCommit : public ObjectWrap { | |||
| 38 | 38 | static Handle<Value> Offset(const Arguments& args); | |
| 39 | 39 | static Handle<Value> Committer(const Arguments& args); | |
| 40 | 40 | static Handle<Value> Author(const Arguments& args); | |
| 41 | - static Handle<Value> Tree(const Arguments& args); | ||
| 42 | - static void TreeWork(uv_work_t* req); | ||
| 43 | - static void TreeAfterWork(uv_work_t* req); | ||
| 44 | - | ||
| 45 | - struct TreeBaton { | ||
| 46 | - uv_work_t request; | ||
| 47 | - int error_code; | ||
| 48 | - const git_error* error; | ||
| 49 | - git_tree * tree_out; | ||
| 50 | - Persistent<Value> commitReference; | ||
| 51 | - const git_commit * commit; | ||
| 52 | - Persistent<Function> callback; | ||
| 53 | - }; | ||
| 54 | 41 | static Handle<Value> TreeId(const Arguments& args); | |
| 55 | 42 | static Handle<Value> ParentCount(const Arguments& args); | |
| 56 | 43 | static Handle<Value> Parent(const Arguments& args); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,75 +1,17 @@ | |||
| 1 | - var git = require('../'); | ||
| 1 | + var git = require('../'), | ||
| 2 | + Blob = git.Blob; | ||
| 2 | 3 | ||
| 3 | 4 | /** | |
| 4 | - * Blob convenience class constructor. | ||
| 5 | - * | ||
| 6 | - * @constructor | ||
| 7 | - * @param {git.raw.Blob} [rawBlob = new git.raw.Blob(rawRepo)] Raw blob object. | ||
| 5 | + * Replace old content method with something nicer. | ||
| 8 | 6 | */ | |
| 9 | - var Blob = function(rawBlob) { | ||
| 10 | - if (!(rawBlob instanceof git.raw.Blob)) { | ||
| 11 | - throw new Error('First parameter for Blob must be a raw blob'); | ||
| 12 | - } | ||
| 13 | - this.rawBlob = rawBlob; | ||
| 7 | + var oldContent = Blob.prototype.content; | ||
| 8 | + Blob.prototype.content = function() { | ||
| 9 | + return oldContent.call(this).toBuffer(this.size()); | ||
| 14 | 10 | }; | |
| 15 | 11 | ||
| 16 | 12 | /** | |
| 17 | - * Retrieve the blob's raw content buffer. | ||
| 13 | + * Retrieve the blob's content as String. | ||
| 18 | 14 | */ | |
| 19 | - Blob.prototype.rawContent = function() { | ||
| 20 | - return this.rawBlob.content().toBuffer(this.size()); | ||
| 15 | + Blob.prototype.toString = function() { | ||
| 16 | + return this.content().toString(); | ||
| 21 | 17 | }; | |
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * Retrieve the blob's length. | ||
| 25 | - */ | ||
| 26 | - Blob.prototype.size = function() { | ||
| 27 | - return this.rawBlob.size(); | ||
| 28 | - }; | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * Retrieve the blob's content. | ||
| 32 | - */ | ||
| 33 | - Blob.prototype.content = function(callback) { | ||
| 34 | - var content = this.rawContent(); | ||
| 35 | - return content.toString(); | ||
| 36 | - }; | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * Create a new blob from the file at the given path. | ||
| 40 | - * | ||
| 41 | - * @param {String} path Full path to the file. | ||
| 42 | - * @param {Blob~createFromFileCallback} callback | ||
| 43 | - */ | ||
| 44 | - Blob.prototype.createFromFile = function(path, callback) { | ||
| 45 | - /** | ||
| 46 | - * @callback Blob~createFromFileCallback Callback executed after blob is created. | ||
| 47 | - * @param {GitError|null} error An Error or null if successful. | ||
| 48 | - * @param {Blob|null} blob The new blob or null. | ||
| 49 | - */ | ||
| 50 | - git.raw.Blob.createFromFile(path, self.rawRepo, function blobCreateFromFileCallback(error, rawBlob) { | ||
| 51 | - if (error) return callback(error); | ||
| 52 | - callback(null, new Blob(rawBlob)); | ||
| 53 | - }); | ||
| 54 | - }; | ||
| 55 | - | ||
| 56 | - /** | ||
| 57 | - * Create a new blob from the given buffer. | ||
| 58 | - * | ||
| 59 | - * @param {Buffer} buffer Buffer used to create blob. | ||
| 60 | - * @param {Blob~createFromBufferCallback} callback | ||
| 61 | - */ | ||
| 62 | - Blob.prototype.createFromFile = function(path, callback) { | ||
| 63 | - /** | ||
| 64 | - * @callback Blob~createFromBufferCallback Callback executed after blob is created. | ||
| 65 | - * @param {GitError|null} error An Error or null if successful. | ||
| 66 | - * @param {Blob|null} content The new blob or null. | ||
| 67 | - */ | ||
| 68 | - var self = this; | ||
| 69 | - self.rawBlob.createFromBuffer(buffer, self.rawRepo, function blobCreateFromBufferCallback(error, rawBlob) { | ||
| 70 | - if (error) return callback(error); | ||
| 71 | - callback(null, new Blob(rawBlob)); | ||
| 72 | - }); | ||
| 73 | - }; | ||
| 74 | - | ||
| 75 | - exports.blob = Blob; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,31 +1,6 @@ | |||
| 1 | - var git = require( '../' ), | ||
| 2 | - events = require('events'); | ||
| 3 | - | ||
| 4 | - /** | ||
| 5 | - * Convenience commit constructor. | ||
| 6 | - * | ||
| 7 | - * @constructor | ||
| 8 | - * @param {git.raw.Repo} rawRepo Raw repository object. | ||
| 9 | - * @param {git.raw.Commit} [rawCommit = new git.raw.Commit(rawRepo)] Raw commit object. | ||
| 10 | - */ | ||
| 11 | - var Commit = function(repo, rawCommit) { | ||
| 12 | - if (!(repo instanceof git.repo)) { | ||
| 13 | - throw new Error('First parameter for Commit must be a raw repo'); | ||
| 14 | - } | ||
| 15 | - this.repo = repo; | ||
| 16 | - | ||
| 17 | - if (!(rawCommit instanceof git.raw.Commit)) { | ||
| 18 | - throw new Error('Second parameter for Commit must be a raw commit'); | ||
| 19 | - } | ||
| 20 | - this.rawCommit = rawCommit; | ||
| 21 | - }; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * Retrieve the commit's OID. | ||
| 25 | - */ | ||
| 26 | - Commit.prototype.oid = function() { | ||
| 27 | - return new git.oid(this.rawCommit.oid()); | ||
| 28 | - }; | ||
| 1 | + var git = require('../'), | ||
| 2 | + Commit = git.Commit, | ||
| 3 | + events = require('events'); | ||
| 29 | 4 | ||
| 30 | 5 | /** | |
| 31 | 6 | * Retrieve the SHA. | |
@@ -34,66 +9,25 @@ Commit.prototype.sha = function() { | |||
| 34 | 9 | return this.oid().sha(); | |
| 35 | 10 | }; | |
| 36 | 11 | ||
| 37 | - /** | ||
| 38 | - * Retrieve the message | ||
| 39 | - */ | ||
| 40 | - Commit.prototype.message = function() { | ||
| 41 | - return this.rawCommit.message(); | ||
| 42 | - }; | ||
| 43 | - | ||
| 44 | 12 | /** | |
| 45 | 13 | * Retrieve the commit time as a unix timestamp. | |
| 46 | 14 | */ | |
| 47 | - Commit.prototype.time = function() { | ||
| 48 | - return this.rawCommit.time() * 1000; | ||
| 15 | + Commit.prototype.timeMs = function() { | ||
| 16 | + return this.time() * 1000; | ||
| 49 | 17 | }; | |
| 50 | 18 | ||
| 51 | 19 | /** | |
| 52 | 20 | * Retrieve the commit time as a Date object. | |
| 53 | 21 | */ | |
| 54 | 22 | Commit.prototype.date = function() { | |
| 55 | - return new Date(this.time()); | ||
| 56 | - }; | ||
| 57 | - | ||
| 58 | - /** | ||
| 59 | - * Retrieve the commit's positive or negative timezone offset, in minutes from UTC. | ||
| 60 | - */ | ||
| 61 | - Commit.prototype.offset = function(callback) { | ||
| 62 | - return this.rawCommit.offset(); | ||
| 63 | - }; | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | - * Retrieve the commit's author signature. | ||
| 67 | - */ | ||
| 68 | - Commit.prototype.author = function() { | ||
| 69 | - return this.rawCommit.author(); | ||
| 23 | + return new Date(this.timeMs()); | ||
| 70 | 24 | }; | |
| 71 | 25 | ||
| 72 | 26 | /** | |
| 73 | - * Retrieve the commit's committer. | ||
| 74 | - */ | ||
| 75 | - Commit.prototype.committer = function() { | ||
| 76 | - return this.rawCommit.committer(); | ||
| 77 | - }; | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * Retrieve the tree for this commit. | ||
| 81 | - * | ||
| 82 | - * @param {Commit~getTreeCallback} callback | ||
| 27 | + * Get the tree associated with this commit. | ||
| 83 | 28 | */ | |
| 84 | 29 | Commit.prototype.getTree = function(callback) { | |
| 85 | - /** | ||
| 86 | - * @callback Commit~getTreeCallback Callback executed on tree retrieval | ||
| 87 | - * @param {GitError|null} error An Error or null if successful. | ||
| 88 | - * @param {Tree|null} Tree | ||
| 89 | - */ | ||
| 90 | - | ||
| 91 | - var self = this; | ||
| 92 | - this.rawCommit.tree(function(error, rawTree) { | ||
| 93 | - if (error) return callback(error); | ||
| 94 | - | ||
| 95 | - callback(null, new git.tree(self.repo, rawTree)); | ||
| 96 | - }); | ||
| 30 | + this.repo.getTree(this.treeId(), callback); | ||
| 97 | 31 | }; | |
| 98 | 32 | ||
| 99 | 33 | /** | |
@@ -103,18 +37,16 @@ Commit.prototype.getTree = function(callback) { | |||
| 103 | 37 | * @param {String} path | |
| 104 | 38 | * @param {Commit~fileCallback} callback | |
| 105 | 39 | */ | |
| 106 | - Commit.prototype.file = function(path, callback) { | ||
| 40 | + Commit.prototype.getFile = function(path, callback) { | ||
| 107 | 41 | /** | |
| 108 | 42 | * @callback Commit~fileCallback Callback executed on file retrieval. | |
| 109 | 43 | * @param {GitError|null} error An Error or null if successful. | |
| 110 | 44 | * @param {Entry|null} file Retrieved file entry. | |
| 111 | 45 | */ | |
| 112 | 46 | this.getTree(function (error, tree) { | |
| 113 | 47 | if (error) return callback(error); | |
| 114 | - tree.entry(path, function(error, entry) { | ||
| 115 | - if (error) return callback(error); | ||
| 116 | - callback(null, entry); | ||
| 117 | - }); | ||
| 48 | + | ||
| 49 | + tree.getEntryByPath(path, callback); | ||
| 118 | 50 | }); | |
| 119 | 51 | }; | |
| 120 | 52 | ||
@@ -132,7 +64,7 @@ Commit.prototype.history = function() { | |||
| 132 | 64 | var event = new events.EventEmitter(); | |
| 133 | 65 | ||
| 134 | 66 | var oid = this.oid(); | |
| 135 | - var revwalk = new git.revwalk(this.repo, this.repo.rawRepo.createRevWalk()); | ||
| 67 | + var revwalk = this.repo.createRevWalk(); | ||
| 136 | 68 | var commits = []; | |
| 137 | 69 | event.start = function() { | |
| 138 | 70 | revwalk.walk(oid, function commitRevWalk(error, commit) { | |
@@ -170,24 +102,23 @@ Commit.prototype.history = function() { | |||
| 170 | 102 | * | |
| 171 | 103 | * @param {Commit~parentsCallback} callback | |
| 172 | 104 | */ | |
| 173 | - Commit.prototype.parents = function(callback) { | ||
| 105 | + Commit.prototype.getParents = function(callback) { | ||
| 174 | 106 | /** | |
| 175 | 107 | * @callback Commit~parentsCallback Callback executed on parents retrieval. | |
| 176 | 108 | * @param {GitError|null} error An Error or null if successful. | |
| 177 | 109 | * @param {Commit[]|null} parents Commit's parent(s). | |
| 178 | 110 | */ | |
| 179 | 111 | var self = this; | |
| 180 | - | ||
| 181 | - function processParents(rawCommit, n, acc, callback) { | ||
| 112 | + function processParents(commit, n, acc, callback) { | ||
| 182 | 113 | if (n < 0) return callback(null, acc); | |
| 183 | 114 | ||
| 184 | - rawCommit.parent(n, function nextParent(error, rawParentCommit) { | ||
| 115 | + self.repo.getCommit(self.parentId(n), function nextParent(error, parent) { | ||
| 185 | 116 | if (error) return callback(error); | |
| 186 | - processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback); | ||
| 117 | + processParents(parent, n-1, acc.concat([parent]), callback); | ||
| 187 | 118 | }); | |
| 188 | 119 | } | |
| 189 | 120 | ||
| 190 | - processParents(this.rawCommit, this.rawCommit.parentCount() - 1, [], callback); | ||
| 121 | + processParents(this, this.parentCount() - 1, [], callback); | ||
| 191 | 122 | }; | |
| 192 | 123 | ||
| 193 | 124 | /** | |
@@ -196,14 +127,14 @@ Commit.prototype.parents = function(callback) { | |||
| 196 | 127 | * | |
| 197 | 128 | * @param {Commit~parentsDiffTreesCallback} callback | |
| 198 | 129 | */ | |
| 199 | - Commit.prototype.parentsDiffTrees = function(callback) { | ||
| 130 | + Commit.prototype.diff = function(callback) { | ||
| 200 | 131 | /** | |
| 201 | 132 | * @callback Commit~parentsDiffTreesCallback Callback executed on diff trees retrieval. | |
| 202 | 133 | * @param {GitError|null} error An Error or null if successful. | |
| 203 | 134 | * @param {DiffList[]|null} diffLists Array of DiffTrees showing changes between this commit and its parent(s) | |
| 204 | 135 | */ | |
| 205 | 136 | var self = this; | |
| 206 | - self.parents(function commitParents(error, parents) { | ||
| 137 | + self.getParents(function commitParents(error, parents) { | ||
| 207 | 138 | if (error) return callback(error); | |
| 208 | 139 | ||
| 209 | 140 | var parentDiffLists = []; | |
@@ -227,5 +158,3 @@ Commit.prototype.parentsDiffTrees = function(callback) { | |||
| 227 | 158 | }); | |
| 228 | 159 | }); | |
| 229 | 160 | }; | |
| 230 | - | ||
| 231 | - exports.commit = Commit; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments