mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-16 11:50:10 +08:00
Implement open
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
const updateIssue = require('./update-issue');
|
||||
|
||||
module.exports = function (context) {
|
||||
return updateIssue(context, {state: 'open'});
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
module.exports = (context, ...labels) => {
|
||||
// FIXME: check that it has the label first, or handle expected error:
|
||||
// {"message":"Label does not exist","documentation_url":"https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue"}
|
||||
return Promise.all(labels.map(label => {
|
||||
return context.github.issues.removeLabel(
|
||||
context.payload.toIssue({name: label})
|
||||
);
|
||||
}));
|
||||
};
|
||||
@@ -35,6 +35,11 @@ let IssuePlugin = (superclass) => class extends superclass {
|
||||
return this;
|
||||
}
|
||||
|
||||
open(){
|
||||
this._setCommentData({open: true})
|
||||
return this;
|
||||
}
|
||||
|
||||
close(){
|
||||
this._setCommentData({close: true})
|
||||
return this;
|
||||
@@ -117,6 +122,11 @@ class IssueEvaluator extends base.Evaluator {
|
||||
);
|
||||
}
|
||||
|
||||
if (workflow.issueActions.open !== undefined) {
|
||||
promises.push(
|
||||
context.github.issues.edit(context.payload.toIssue({state: "open"}))
|
||||
);
|
||||
}
|
||||
|
||||
if (workflow.issueActions.close !== undefined) {
|
||||
promises.push(
|
||||
|
||||
@@ -24,7 +24,18 @@ describe('issues plugin', () => {
|
||||
w = new workflow.Workflow();
|
||||
evaluator = new issues.Evaluator;
|
||||
})
|
||||
describe('closing', () => {
|
||||
describe('state', () => {
|
||||
it('opens an issue', () => {
|
||||
w.open()
|
||||
|
||||
Promise.all(evaluator.evaluate(w, context));
|
||||
expect(github.issues.edit).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
number: 6,
|
||||
state: 'open',
|
||||
});
|
||||
});
|
||||
it('closes an issue', () => {
|
||||
w.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user