Skip to content

Commit 15b69aa

Browse files
committed
Added isStarred() method
1 parent 4683ba8 commit 15b69aa

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ Get contributors list with additions, deletions, and commit counts.
238238
repo.contributors(function(err, data) {});
239239
```
240240

241+
Check if a repository is starred.
242+
243+
```js
244+
repo.isStarred(owner, repository, function(err) {});
245+
```
246+
241247
## User API
242248

243249

src/github.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,13 @@
845845

846846
_request('GET', url, null, cb);
847847
};
848+
849+
// Check if a repository is starred.
850+
// --------
851+
852+
this.isStarred = function(owner, repository, cb) {
853+
_request('GET', '/user/starred/' + owner + '/' + repository, null, cb);
854+
};
848855
};
849856

850857
// Gists API

test/test.repo.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (typeof window === 'undefined') { // We're in NodeJS
3737
}
3838
}
3939

40-
describe('Github.Repository', function() {
40+
describe.only('Github.Repository', function() {
4141
before(function() {
4242
github = new Github({
4343
username: testUser.USERNAME,
@@ -211,6 +211,13 @@ describe('Github.Repository', function() {
211211
done();
212212
});
213213
});
214+
215+
it('should check if the repo is starred', function(done) {
216+
repo.isStarred('michael', 'github', function(err) {
217+
err.error.should.equal(404);
218+
done();
219+
});
220+
});
214221
});
215222

216223
var repoTest = Math.floor(Math.random() * 100000);

0 commit comments

Comments
 (0)