Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19b6184

Browse files
deecewanAurelioDeRosa
authored andcommitted
feature(repository): add getBranch
closes github-tools#372
1 parent fb0669c commit 19b6184

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Repository.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ class Repository extends Requestable {
152152
return this._request('GET', `/repos/${this.__fullname}/git/blobs/${sha}`, null, cb, 'raw');
153153
}
154154

155+
/**
156+
* Get a single branch
157+
* @see https://developer.github.com/v3/repos/branches/#get-branch
158+
* @param {string} branch - the name of the branch to fetch
159+
* @param {Requestable.callback} cb - will receive the branch from the API
160+
* @returns {Promise} - the promise for the http request
161+
*/
162+
getBranch(branch, cb) {
163+
return this._request('GET', `/repos/${this.__fullname}/branches/${branch}`, null, cb);
164+
}
165+
155166
/**
156167
* Get a commit from the repository
157168
* @see https://developer.github.com/v3/repos/commits/#get-a-single-commit

test/repository.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ describe('Repository', function() {
5252
}));
5353
});
5454

55+
it('should get a branch', function(done) {
56+
remoteRepo.getBranch('master', assertSuccessful(done, function(err, content) {
57+
expect(content.name).to.be('master');
58+
59+
done();
60+
}));
61+
});
62+
5563
it('should show repo contents', function(done) {
5664
remoteRepo.getContents('master', '', false, assertSuccessful(done, function(err, contents) {
5765
expect(contents).to.be.an.array();

0 commit comments

Comments
 (0)