Skip to content

Commit 38d5704

Browse files
必隆fengmk2
authored andcommitted
add: Get the raw file contents for a blob by blob sha
1 parent a39afb0 commit 38d5704

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/repository_file.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ function RepositoryFile(client) {
2323
this.constructor.super_.call(this, client, '/projects/:id/repository/files');
2424
}
2525
util.inherits(RepositoryFile, restful.RESTFulResource);
26+
27+
/**
28+
* Get the raw file contents for a blob by blob sha.
29+
*
30+
* @param {Object} params
31+
* - {String} id The ID of a project
32+
* - {String} sha The blob sha
33+
* @param {Function} callback
34+
*/
35+
RepositoryFile.prototype.getContents = function (params, callback) {
36+
this.client.request('get', '/projects/:id/repository/raw_blobs/:sha', params, callback);
37+
};

test/repository_file.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,14 @@ describe('repository_file.test.js', function () {
197197
});
198198
});
199199
});
200+
201+
describe('client.repositoryFiles.getContents()', function () {
202+
it('should return repository file contents', function (done) {
203+
client.repositoryFiles.getContents({id: 55045, sha: '946579807281bd26b75b91986c78f15ad0bd40f7'}, function (err, contents) {
204+
should.not.exists(err);
205+
contents.should.be.a.String;
206+
done();
207+
});
208+
});
209+
});
200210
});

0 commit comments

Comments
 (0)