Skip to content

Commit 12cbeed

Browse files
committed
Dropped Repository#list in favor of a more generic Repository#getTree.
1 parent 23e6dcd commit 12cbeed

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

github.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
Github.User = function() {
3535
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) {
3737
cb(err, res);
3838
});
3939
}
@@ -83,10 +83,10 @@
8383
// Retrieve the tree a commit points to
8484
// -------
8585

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) {
8888
if (err) return cb(err);
89-
cb(null, res.sha);
89+
cb(null, res.tree);
9090
});
9191
};
9292

@@ -166,21 +166,13 @@
166166
});
167167
};
168168

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-
178169

179170
// Read file at given path
180171
// -------
181172

182173
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);
184176
var file = _.select(tree, function(file) {
185177
return file.path === path;
186178
})[0];
@@ -210,13 +202,11 @@
210202

211203
this.write = function(branch, path, content, message, cb) {
212204
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);
220210
});
221211
});
222212
});
@@ -229,7 +219,7 @@
229219
// -------
230220

231221
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"});
233223
};
234224

235225
this.getUser = function() {

0 commit comments

Comments
 (0)