diff --git a/README.md b/README.md index 30802209..e4cc176a 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,12 @@ Check if a repository is starred. repo.isStarred(owner, repository, function(err) {}); ``` +Star a repository. + +```js +repo.star(owner, repository, function(err) {}); +``` + ## User API diff --git a/src/github.js b/src/github.js index 8548a387..744a0cc7 100644 --- a/src/github.js +++ b/src/github.js @@ -852,6 +852,13 @@ this.isStarred = function(owner, repository, cb) { _request('GET', '/user/starred/' + owner + '/' + repository, null, cb); }; + + // Star a repository. + // -------- + + this.star = function(owner, repository, cb) { + _request('PUT', '/user/starred/' + owner + '/' + repository, null, cb) + }; }; // Gists API diff --git a/test/test.repo.js b/test/test.repo.js index dce61fc4..fa600ead 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -505,6 +505,17 @@ describe('Creating new Github.Repository', function() { }); }); }); + + it('should star the repo', function(done) { + repo.star(testUser.USERNAME, repoTest, function(err) { + should.not.exist(err); + + repo.isStarred(testUser.USERNAME, repoTest, function(err) { + should.not.exist(err); + done(); + }); + }); + }); }); describe('deleting a Github.Repository', function() {