From dd7edcc6b20a5562d8427700d257745a766cd9b5 Mon Sep 17 00:00:00 2001 From: Keith Thornhill Date: Tue, 1 Apr 2014 17:02:08 -0700 Subject: [PATCH] add listStatuses and listHeads. re-implement listBranches using listHeads --- github.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/github.js b/github.js index bc63ab0d..f8685e88 100644 --- a/github.js +++ b/github.js @@ -306,13 +306,33 @@ }); }; - // List all branches of a repository + // List all branch names of a repository // ------- this.listBranches = function(cb) { - _request("GET", repoPath + "/git/refs/heads", null, function(err, heads) { + that.listHeads(function(err, heads) { if (err) return cb(err); cb(null, _.map(heads, function(head) { return _.last(head.ref.split('/')); })); + }) + }; + + // List all heads of a repository + // ------- + + this.listHeads = function(cb) { + _request("GET", repoPath + "/git/refs/heads", null, function(err, heads) { + if (err) return cb(err); + cb(null, heads) + }); + } + + // List all statuses for a given ref + // ------- + + this.listStatuses = function(ref, cb) { + _request("GET", repoPath + "/statuses/" + ref, null, function(err, statuses) { + if (err) return cb(err); + cb(null, statuses); }); };