Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90fb78b

Browse files
j-rewertsclayreimann
authored andcommitted
feature: Add commit author (#547)
1 parent38530fa commit90fb78b

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

‎lib/Repository.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,26 @@ class Repository extends Requestable {
334334
*@param {string} parent - the SHA of the parent commit
335335
*@param {string} tree - the SHA of the tree for this commit
336336
*@param {string} message - the commit message
337+
*@param {Object} [options] - commit options
338+
*@param {Object} [options.author] - the author of the commit
339+
*@param {Object} [options.commiter] - the committer
337340
*@param {Requestable.callback} cb - will receive the commit that is created
338341
*@return {Promise} - the promise for the http request
339342
*/
340-
commit(parent,tree,message,cb){
343+
commit(parent,tree,message,options,cb){
344+
if(typeofoptions==='function'){
345+
cb=options;
346+
options={};
347+
}
348+
341349
letdata={
342350
message,
343351
tree,
344352
parents:[parent],
345353
};
346354

355+
data=Object.assign({},options,data);
356+
347357
returnthis._request('POST',`/repos/${this.__fullname}/git/commits`,data,cb)
348358
.then((response)=>{
349359
this.__currentTree.sha=response.data.sha;// Update latest commit

‎test/repository.spec.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,45 @@ describe('Repository', function() {
600600
}));
601601
});
602602

603+
it('should succeed on proper commit',function(done){
604+
letparentSHA='';
605+
lettreeSHA='';
606+
remoteRepo.getRef('heads/master').then((ref)=>{
607+
parentSHA=ref.data.object.sha;
608+
returnremoteRepo.getCommit(parentSHA);
609+
}).then((commit)=>{
610+
treeSHA=commit.data.tree.sha;
611+
returnremoteRepo.commit(parentSHA,treeSHA,'is this thing on?');
612+
}).then((commit)=>{
613+
expect(commit.data.author).to.have.own('name','Mike de Boer');
614+
expect(commit.data.author).to.have.own('email','mike@c9.io');
615+
done();
616+
});
617+
});
618+
619+
it('should allow commit to change author',function(done){
620+
letparentSHA='';
621+
lettreeSHA='';
622+
remoteRepo.getRef('heads/master').then((ref)=>{
623+
parentSHA=ref.data.object.sha;
624+
returnremoteRepo.getCommit(parentSHA);
625+
}).then((commit)=>{
626+
treeSHA=commit.data.tree.sha;
627+
returnremoteRepo.commit(parentSHA,treeSHA,'Who made this commit?',{
628+
author:{
629+
name:'Jimothy Halpert',
630+
email:'jim@dundermifflin.com',
631+
},
632+
});
633+
}).then((commit)=>{
634+
expect(commit.data.author).to.have.own('name','Jimothy Halpert');
635+
expect(commit.data.author).to.have.own('email','jim@dundermifflin.com');
636+
done();
637+
}).catch((err)=>{
638+
throwerr;
639+
});
640+
});
641+
603642
it('should create a release',function(done){
604643
constreleaseDef={
605644
name:releaseName,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp