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

Commit46dd1d7

Browse files
fklingclayreimann
authored andcommitted
1 parentf075749 commit46dd1d7

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

‎lib/Gist.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,27 @@ class Gist extends Requestable {
108108
returnthis._request204or404(`/gists/${this.__id}/star`,null,cb);
109109
}
110110

111+
/**
112+
* List the gist's commits
113+
*@see https://developer.github.com/v3/gists/#list-gist-commits
114+
*@param {Requestable.callback} [cb] - will receive the array of commits
115+
*@return {Promise} - the Promise for the http request
116+
*/
117+
listCommits(cb){
118+
returnthis._requestAllPages(`/gists/${this.__id}/commits`,null,cb);
119+
}
120+
121+
/**
122+
* Fetch one of the gist's revision.
123+
*@see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
124+
*@param {string} revision - the id of the revision
125+
*@param {Requestable.callback} [cb] - will receive the revision
126+
*@return {Promise} - the Promise for the http request
127+
*/
128+
getRevision(revision,cb){
129+
returnthis._request('GET',`/gists/${this.__id}/${revision}`,null,cb);
130+
}
131+
111132
/**
112133
* List the gist's comments
113134
*@see https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist

‎test/gist.spec.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('Gist', function() {
1010
letgistId;
1111
letgithub;
1212
letcommentId;
13+
letrevisionId;
1314

1415
before(function(){
1516
github=newGithub({
@@ -51,6 +52,7 @@ describe('Gist', function() {
5152
expect(gist).to.have.own('public',testGist.public);
5253
expect(gist).to.have.own('description',testGist.description);
5354
gistId=gist.id;
55+
revisionId=gist.history[0].version;
5456

5557
done();
5658
}));
@@ -99,6 +101,36 @@ describe('Gist', function() {
99101
it('should delete comment',function(done){
100102
gist.deleteComment(commentId,assertSuccessful(done));
101103
});
104+
105+
it('should update gist',function(done){
106+
constnewGist={
107+
files:{
108+
'README.md':{
109+
content:'README updated',
110+
},
111+
},
112+
};
113+
gist.update(newGist,assertSuccessful(done,function(err,gist){
114+
expect(gist.history.length).to.be(2);
115+
expect(gist.files['README.md']).to.have.own('content',newGist.files['README.md'].content);
116+
done();
117+
}));
118+
});
119+
120+
it('should list commits',function(done){
121+
gist.listCommits(assertSuccessful(done,function(err,commits){
122+
expect(commits).to.be.an.array();
123+
done();
124+
}));
125+
});
126+
127+
it('should get revision',function(done){
128+
gist.getRevision(revisionId,assertSuccessful(done,function(err,gist){
129+
expect(gist.history.length).to.be(1);
130+
expect(gist.files['README.md']).to.have.own('content',testGist.files['README.md'].content);
131+
done();
132+
}));
133+
});
102134
});
103135

104136
describe('deleting',function(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp