Skip to content

Commit 9e0f89a

Browse files
committed
Get contributors list with additions, deletions, and commit counts
1 parent ffd7226 commit 9e0f89a

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

github.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,28 @@
460460
_request("GET", repoPath, null, cb);
461461
};
462462

463+
// Show repository contributors
464+
// -------
465+
466+
this.contributors = function (cb, retry) {
467+
retry = retry || 1000;
468+
var self = this;
469+
_request("GET", repoPath + "/stats/contributors", null, function (err, data, response) {
470+
if (err) return cb(err);
471+
472+
if (response.status == "202") {
473+
setTimeout(
474+
function () {
475+
self.contributors(cb, retry);
476+
},
477+
retry
478+
);
479+
} else {
480+
cb(err, data);
481+
}
482+
});
483+
};
484+
463485
// Get contents
464486
// --------
465487

test/test.repo.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ test("Repo API", function(t) {
3333
});
3434
});
3535

36+
t.test('repo.contributors', function(q) {
37+
repo.contributors(function(err, res) {
38+
q.error(err, 'repo contributors');
39+
q.ok(res instanceof Array, 'list of contributors');
40+
q.ok(res.length, 'at least one contributor');
41+
q.ok(res[0].author, 'contributor info');
42+
q.ok(res[0].total, 'total number of commits');
43+
q.ok(res[0].weeks, 'weekly hash');
44+
q.end();
45+
});
46+
});
47+
3648
//@TODO repo.branch, repo.pull
3749

3850
t.test('repo.listBranches', function(q) {

0 commit comments

Comments
 (0)