This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 918181d  tweak issue class and issue opened hook
918181d is described below

commit 918181dfb43ef14747011d8702b4b837aadf0d7e
Author: plainheart <y...@all-my-life.cn>
AuthorDate: Mon Nov 29 15:17:12 2021 +0800

    tweak issue class and issue opened hook
---
 index.js     | 24 ++++++------------------
 src/issue.js | 16 ----------------
 2 files changed, 6 insertions(+), 34 deletions(-)

diff --git a/index.js b/index.js
index 16eb287..f46755d 100644
--- a/index.js
+++ b/index.js
@@ -11,34 +11,22 @@ module.exports = (/** @type import('probot').Probot */ app) 
=> {
 
         await issue.init();
 
-        // Ignore comment because it will commented when adding invalid label
-        const comment = !issue.response || issue.response === 
text.NOT_USING_TEMPLATE
-            ? Promise.resolve()
-            : commentIssue(context, issue.response);
-
-        await comment;
+        await commentIssue(context, text.ISSUE_CREATED);
 
         const addLabels = issue.addLabels.length
-            ? context.octokit.issues.addLabels(
+            && context.octokit.issues.addLabels(
                 context.issue({
                     labels: issue.addLabels
                 })
-              )
-            : Promise.resolve();
+            );
 
-        const removeLabel = issue.removeLabel
-            ? getRemoveLabel(context, issue.removeLabel)
-            : Promise.resolve();
+        const removeLabel = issue.removeLabel && getRemoveLabel(context, 
issue.removeLabel);
 
-        // then add and remove label
+        // add and remove label
         await Promise.all([addLabels, removeLabel]);
 
         // translate finally
-        const translate = issue.response === text.ISSUE_CREATED
-            ? translateIssue(context, issue)
-            : Promise.resolve();
-
-        return translate;
+        return translateIssue(context, issue);
     });
 
     app.on(['issues.closed'], context => {
diff --git a/src/issue.js b/src/issue.js
index bf641ac..9233207 100644
--- a/src/issue.js
+++ b/src/issue.js
@@ -1,4 +1,3 @@
-const text = require('./text');
 const label = require('./label');
 const { isCommitter } = require('./coreCommitters');
 const { translate } = require('./translator');
@@ -14,8 +13,6 @@ class Issue {
         // false -> translated -> not in English
         this.translatedTitle = null;
         this.translatedBody = null;
-        this.issueType = null;
-        this.response = null;
         this.addLabels = [];
         this.removeLabel = null;
     }
@@ -50,19 +47,6 @@ class Issue {
             this.translatedBody = res.lang !== 'en' && [res.translated, 
res.lang];
         }
     }
-
-    _computeResponse() {
-        switch(this.context.payload.action) {
-            case 'opened':
-            case 'reopened':
-                this.response = text.ISSUE_CREATED;
-                break;
-            case 'edited':
-                this.response = text.ISSUE_UPDATED;
-                this.removeLabel = label.WAITING_FOR_HELP;
-                break;
-        }
-    }
 }
 
 module.exports = Issue;

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to