Skip to content

Commit fb54ae3

Browse files
author
Ændrew Rininsland
committed
Merge pull request #161 from eugef/master
Get contributors list with additions, deletions, and commit counts
2 parents 4cf2432 + 3ca1c11 commit fb54ae3

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ Delete a reference.
185185
repo.deleteRef('heads/gh-pages', function(err) {});
186186
```
187187

188+
Get contributors list with additions, deletions, and commit counts.
189+
190+
```js
191+
repo.contributors(function(err, data) {});
192+
```
188193

189194
## User API
190195

github.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,27 @@
493493
_request("GET", repoPath, null, cb);
494494
};
495495

496+
// Show repository contributors
497+
// -------
498+
499+
this.contributors = function (cb, retry) {
500+
retry = retry || 1000;
501+
var self = this;
502+
_request("GET", repoPath + "/stats/contributors", null, function (err, data, response) {
503+
if (err) return cb(err);
504+
if (response.status === 202) {
505+
setTimeout(
506+
function () {
507+
self.contributors(cb, retry);
508+
},
509+
retry
510+
);
511+
} else {
512+
cb(err, data);
513+
}
514+
});
515+
};
516+
496517
// Get contents
497518
// --------
498519

test/test.repo.js

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

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

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

0 commit comments

Comments
 (0)