You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2021/05/18 11:06:45 UTC

[echarts-bot] branch master updated: feat: 1) unlabel waiting-for: comminity if issue was closed by the author self 2) unlabel `invalid` when reopened 3) do nothing if issue author is committer when labeled 4) unlabel `waiting-for: comminity` and close issue when `resolved` is labeled.

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 ea1b003  feat: 1) unlabel waiting-for: comminity if issue was closed by the author self 2) unlabel `invalid` when reopened 3) do nothing if issue author is committer when labeled 4) unlabel `waiting-for: comminity` and close issue when `resolved` is labeled.
ea1b003 is described below

commit ea1b003a28636cce7dc877ea658173c2092c4230
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Tue May 18 19:06:12 2021 +0800

    feat: 1) unlabel waiting-for: comminity if issue was closed by the author self
    2) unlabel `invalid` when reopened
    3) do nothing if issue author is committer when labeled
    4) unlabel `waiting-for: comminity` and close issue when `resolved` is labeled.
---
 index.js | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 010fdc6..e5fb490 100644
--- a/index.js
+++ b/index.js
@@ -26,7 +26,7 @@ module.exports = (app) => {
             : Promise.resolve();
 
         const removeLabel = issue.removeLabel
-            ? getRemoveLabel(issue.removeLabel)
+            ? getRemoveLabel(context, issue.removeLabel)
             : Promise.resolve();
 
         // then add and remove label
@@ -40,16 +40,36 @@ module.exports = (app) => {
         return translate;
     });
 
+    app.on(['issues.closed'], context => {
+        // unlabel waiting-for: comminity if issue was closed by the author self
+        if (context.payload.issue.user.login === context.payload.sender.login) {
+            return getRemoveLabel(context, 'waiting-for: community');
+        }
+    });
+
+    app.on(['issues.reopened'], context => {
+        // unlabel invalid when reopened
+        return getRemoveLabel(context, 'invalid');
+    });
+
     app.on('issues.labeled', async context => {
+        const labelName = context.payload.label.name;
+        const issue = context.payload.issue;
+        const issueAuthor = issue.user.login;
+        if (labelName !== 'resolved' && isCommitter(issue.author_association, issueAuthor)) {
+            //  do nothing if issue author is committer
+            return;
+        }
+
         const replaceAt = function (comment) {
             return replaceAll(
                 comment,
                 'AT_ISSUE_AUTHOR',
-                '@' + context.payload.issue.user.login
+                '@' + issueAuthor
             );
         };
 
-        switch (context.payload.label.name) {
+        switch (labelName) {
             case 'invalid':
                 return Promise.all([commentIssue(context, text.NOT_USING_TEMPLATE), closeIssue(context)]);
 
@@ -76,6 +96,12 @@ module.exports = (app) => {
 
             case 'priority: high':
                 return commentIssue(context, replaceAt(text.ISSUE_TAGGED_PRIORITY_HIGH));
+
+            case 'resolved':
+                return Promise.all([
+                    closeIssue(context),
+                    getRemoveLabel(context, 'waiting-for: community')
+                ]);
         }
     });
 

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