Skip to content

Commit 19b539f

Browse files
committed
Added methods to edit and get an issue
Closes github-toolsgh-284
1 parent 36d6b27 commit 19b539f

File tree

7 files changed

+64
-6
lines changed

7 files changed

+64
-6
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,31 @@ issues.list(options, function(err, issues) {});
389389
To comment in a issue
390390

391391
```js
392-
issues.comment(issue, comment,function(err, comment) {});
392+
issues.comment(issue, comment, function(err, comment) {});
393+
```
394+
395+
To edit an issue
396+
397+
```js
398+
var options = {
399+
title: "Found a bug",
400+
body: "I'm having a problem with this.",
401+
assignee: "assignee_username",
402+
milestone: 1,
403+
state: "open",
404+
labels: [
405+
"Label1",
406+
"Label2"
407+
]
408+
};
409+
410+
issues.edit(issue, options, function (err, issue) {});
411+
```
412+
413+
To get an issue
414+
415+
```js
416+
issues.get(issue, function (err, issue) {});
393417
```
394418

395419
## Search API

dist/github.bundle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.bundle.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,14 @@
10321032
body: comment
10331033
}, cb);
10341034
};
1035+
1036+
this.edit = function (issue, options, cb) {
1037+
_request('PATCH', path + '/' + issue, options, cb);
1038+
};
1039+
1040+
this.get = function (issue, cb) {
1041+
_request('GET', path + '/' + issue, null, cb);
1042+
};
10351043
};
10361044

10371045
// Search API

test/test.issue.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,30 @@ describe('Github.Issue', function() {
3636
});
3737
});
3838
});
39+
40+
it('should edit issues title', function(done) {
41+
issues.list({}, function(err, issuesList) {
42+
issues.edit(issuesList[0].number, {
43+
title: 'Edited title'
44+
}, function(err, res, xhr) {
45+
should.not.exist(err);
46+
xhr.should.be.instanceof(XMLHttpRequest);
47+
res.title.should.equal('Edited title');
48+
49+
done();
50+
});
51+
});
52+
});
53+
54+
it('should get issue', function(done) {
55+
issues.list({}, function(err, issuesList) {
56+
issues.get(issuesList[0].number, function(err, res, xhr) {
57+
should.not.exist(err);
58+
xhr.should.be.instanceof(XMLHttpRequest);
59+
res.number.should.equal(issuesList[0].number);
60+
61+
done();
62+
});
63+
});
64+
});
3965
});

0 commit comments

Comments
 (0)