Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ Delete a reference.
repo.deleteRef('heads/gh-pages', function(err) {});
```

Get contributors list with additions, deletions, and commit counts.

```js
repo.contributors(function(err, data) {});
```

## User API

Expand Down
21 changes: 21 additions & 0 deletions github.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,27 @@
_request("GET", repoPath, null, cb);
};

// Show repository contributors
// -------

this.contributors = function (cb, retry) {
retry = retry || 1000;
var self = this;
_request("GET", repoPath + "/stats/contributors", null, function (err, data, response) {
if (err) return cb(err);
if (response.status === 202) {
setTimeout(
function () {
self.contributors(cb, retry);
},
retry
);
} else {
cb(err, data);
}
});
};

// Get contents
// --------

Expand Down
12 changes: 12 additions & 0 deletions test/test.repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ test("Repo API", function(t) {
});
});

t.test('repo.contributors', function(q) {
repo.contributors(function(err, res) {
q.error(err, 'repo contributors');
q.ok(res instanceof Array, 'list of contributors');
q.ok(res.length, 'at least one contributor');
q.ok(res[0].author, 'contributor info');
q.ok(res[0].total, 'total number of commits');
q.ok(res[0].weeks, 'weekly hash');
q.end();
});
});

//@TODO repo.branch, repo.pull

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