|
33 | 33 |
|
34 | 34 | Github.User = function() { |
35 | 35 | this.repos = function(cb) { |
36 | | - _request("GET", "/user/repos?type=all", null, function(err, res) { |
| 36 | + _request("GET", "/user/repos?type=all&per_page=100", null, function(err, res) { |
37 | 37 | cb(err, res); |
38 | 38 | }); |
39 | 39 | } |
|
83 | 83 | // Retrieve the tree a commit points to |
84 | 84 | // ------- |
85 | 85 |
|
86 | | - this.getTree = function(commit, cb) { |
87 | | - _request("GET", repoPath + "/git/trees/"+commit, null, function(err, res) { |
| 86 | + this.getTree = function(tree, cb) { |
| 87 | + _request("GET", repoPath + "/git/trees/"+tree, null, function(err, res) { |
88 | 88 | if (err) return cb(err); |
89 | | - cb(null, res.sha); |
| 89 | + cb(null, res.tree); |
90 | 90 | }); |
91 | 91 | }; |
92 | 92 |
|
|
166 | 166 | }); |
167 | 167 | }; |
168 | 168 |
|
169 | | - // List all files of a branch |
170 | | - // ------- |
171 | | - |
172 | | - this.list = function(branch, cb) { |
173 | | - _request("GET", repoPath + "/git/trees/" + branch + "?recursive=1", null, function(err, res) { |
174 | | - cb(err, res ? res.tree : null); |
175 | | - }); |
176 | | - }; |
177 | | - |
178 | 169 |
|
179 | 170 | // Read file at given path |
180 | 171 | // ------- |
181 | 172 |
|
182 | 173 | this.read = function(branch, path, cb) { |
183 | | - that.list(branch, function(err, tree) { |
| 174 | + that.getTree(branch+"?recursive=true", function(err, tree) { |
| 175 | + console.log(tree); |
184 | 176 | var file = _.select(tree, function(file) { |
185 | 177 | return file.path === path; |
186 | 178 | })[0]; |
|
210 | 202 |
|
211 | 203 | this.write = function(branch, path, content, message, cb) { |
212 | 204 | that.getRef(branch, function(err, latestCommit) { |
213 | | - that.getTree(latestCommit, function(err, tree) { |
214 | | - that.postBlob(content, function(err, blob) { |
215 | | - that.postTree(tree, path, blob, function(err, tree) { |
216 | | - that.commit(latestCommit, tree, message, function(err, commit) { |
217 | | - that.updateHead(branch, commit, function(err) { |
218 | | - cb(err); |
219 | | - }); |
| 205 | + that.postBlob(content, function(err, blob) { |
| 206 | + that.postTree(latestCommit, path, blob, function(err, tree) { |
| 207 | + that.commit(latestCommit, tree, message, function(err, commit) { |
| 208 | + that.updateHead(branch, commit, function(err) { |
| 209 | + cb(err); |
220 | 210 | }); |
221 | 211 | }); |
222 | 212 | }); |
|
229 | 219 | // ------- |
230 | 220 |
|
231 | 221 | this.getRepo = function(user, repo, branch) { |
232 | | - return new Github.Repository({user: user, name: repo, branch: branch || "master"}); |
| 222 | + return new Github.Repository({user: user, name: repo, branch: branch || "master"}); |
233 | 223 | }; |
234 | 224 |
|
235 | 225 | this.getUser = function() { |
|
0 commit comments