diff --git a/lib/actions/open.js b/lib/actions/open.js deleted file mode 100644 index 27662cd..0000000 --- a/lib/actions/open.js +++ /dev/null @@ -1,5 +0,0 @@ -const updateIssue = require('./update-issue'); - -module.exports = function (context) { - return updateIssue(context, {state: 'open'}); -}; diff --git a/lib/actions/unlabel.js b/lib/actions/unlabel.js deleted file mode 100644 index d4df621..0000000 --- a/lib/actions/unlabel.js +++ /dev/null @@ -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}) - ); - })); -}; diff --git a/lib/plugins/issues.js b/lib/plugins/issues.js index 73d335b..3f2cbeb 100644 --- a/lib/plugins/issues.js +++ b/lib/plugins/issues.js @@ -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( diff --git a/test/plugins/issues.js b/test/plugins/issues.js index 12e6f80..3541cde 100644 --- a/test/plugins/issues.js +++ b/test/plugins/issues.js @@ -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()