From 43ed6bce7838969ada536b19c499ba22d3dec078 Mon Sep 17 00:00:00 2001 From: pik Date: Sat, 28 Nov 2015 18:10:47 +0800 Subject: [PATCH] Add getStatuses repo endpoint * added test for getStatuses * updated Readme to include repo.getStatuses method --- README.md | 6 ++++++ github.js | 12 ++++++++++++ test/test.repo.js | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/README.md b/README.md index 798dd9a9..11ad9424 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,12 @@ Retrieve all available branches (aka heads) of a repository. repo.listBranches(function(err, branches) {}); ``` +Get list of statuses for a particular commit. + +```js +repo.getStatuses(sha, function(err, statuses) {}); +``` + Store contents at a certain path, where files that don't yet exist are created on the fly. You can also provide an optional object literal, (`options` in the example below) containing information about the author and the committer. diff --git a/github.js b/github.js index 098f51f6..dfd3e0e6 100644 --- a/github.js +++ b/github.js @@ -515,6 +515,18 @@ }); }; + // Get the statuses for a particular SHA + // ------- + + this.getStatuses = function(sha, cb) { + _request('GET', repoPath + '/statuses/' + sha, null, function(err, heads, xhr) { + if (err) { + return cb(err); + } + cb(null, heads, xhr); + }) + }; + // Retrieve the tree a commit points to // ------- diff --git a/test/test.repo.js b/test/test.repo.js index 9e992f60..a216b62d 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -97,6 +97,16 @@ describe('Github.Repository', function() { }); }); + it('should get statuses for a SHA from a repo', function(done) { + repo.getStatuses('20fcff9129005d14cc97b9d59b8a3d37f4fb633b', function(err, statuses) { + statuses.length.should.equal(6) + statuses.every(function(status) { + return status.url === 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b' + }).should.equal(true); + done(); + }); + }); + it('should get a SHA from a repo', function(done) { repo.getSha('master', '.gitignore', function(err, sha) { should.not.exist(err);