Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 89088ef

Browse files
dcolensfengmk2
authored andcommitted
feat: Add repository.archive functionality (repo-utils#29)
1 parent 2ec8e6f commit 89088ef

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/resources/repository.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,18 @@ Repository.prototype.createTag = function (params, callback) {
165165
};
166166

167167

168+
/**
169+
* Get the archive for a repo by commit sha.
170+
*
171+
* @param {Object} params
172+
* - {String} id The ID of a project
173+
* - {String} sha The repo sha
174+
* @param {Function} callback
175+
*/
176+
Repository.prototype.archive = function (params, callback) {
177+
params.type = 'archive';
178+
params.contentType = 'buffer';
179+
this.client.request('get', this.path, params, callback);
180+
};
181+
182+

test/repository.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,17 @@ describe.skip('repository.test.js', function () {
235235
});
236236
});
237237
});
238-
238+
239+
describe('client.repository.archive()', function () {
240+
it('should return archive file', function (done) {
241+
client.repository.archive({id: 55045, sha: '946579807281bd26b75b91986c78f15ad0bd40f7'}, function (err, raw) {
242+
should.not.exists(err);
243+
should.exists(raw);
244+
should.ok(Buffer.isBuffer(raw));
245+
raw.should.be.a.Buffer;
246+
raw.length.should.above(0);
247+
done();
248+
});
249+
});
250+
});
239251
});

0 commit comments

Comments
 (0)