Skip to content

Commit f1b479f

Browse files
randalmaiaÆndrew Rininsland
authored andcommitted
Adds issues.comment. Resolves github-tools#209.
1 parent 78c8b78 commit f1b479f

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ To read all the issues of a given repository
322322
issues.list(options, function(err, issues) {});
323323
```
324324

325+
To comment in a issue
326+
327+
```js
328+
issues.comment(issue, comment,function(err, comment) {});
329+
```
330+
325331
## Change Log
326332

327333
### 0.10.X

github.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,14 @@
884884
}
885885
_requestAllPages(path + '?' + query.join("&"), cb);
886886
};
887+
888+
this.comment = function(issue, comment, cb) {
889+
_request("POST", issue.comments_url, {body:comment}, function(err,res) {
890+
cb(err,res);
891+
});
892+
};
893+
894+
887895
};
888896

889897
// Top Level API

test/test.issue.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
var test = require('tape'); //jshint ignore:line
4+
var Github = require("../");
5+
var test_user = require('./user.json');
6+
7+
test("Issues API", function(t) {
8+
var github = new Github({
9+
username: test_user.USERNAME,
10+
password: test_user.PASSWORD,
11+
auth: "basic"
12+
});
13+
14+
var issues = github.getIssues('mikedeboertest', 'TestRepo');
15+
16+
t.test('issues.list', function(q) {
17+
issues.list({},function(err, issues) {
18+
q.error(err);
19+
t.equals(issues.length > 0, true, 'Issues!');
20+
q.end();
21+
});
22+
t.end();
23+
});
24+
25+
t.test('issues.comment', function(q) {
26+
issues.list({},function(err, issuesList) {
27+
issues.comment(issuesList[0], 'Comment test', function(err, res){
28+
q.error(err);
29+
t.equals(res.body, 'Comment test', 'Comments!');
30+
q.end();
31+
});
32+
});
33+
});
34+
35+
36+
});

0 commit comments

Comments
 (0)