[incubator-echarts-bot] 20/32: feat: pr label

2020-10-27 Thread wangzx
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/incubator-echarts-bot.git

commit 27926dba30a77a7a07bb7123f62bcb1992199514
Author: Ovilia 
AuthorDate: Mon Feb 17 11:47:52 2020 +0800

feat: pr label
---
 index.js| 27 ---
 src/text.js |  4 
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index fe0422a..2c51d00 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,4 @@
 const Issue = require('./src/issue');
-const coreCommitters = require('./src/coreCommitters');
 const text = require('./src/text');
 
 module.exports = app => {
@@ -33,7 +32,6 @@ module.exports = app => {
 );
 };
 
-// console.log(context.payload);
 switch (context.payload.label.name) {
 case 'invalid':
 return Promise.all([commentIssue(context, 
text.NOT_USING_TEMPLATE), closeIssue(context)]);
@@ -44,6 +42,15 @@ module.exports = app => {
 case 'inactive':
 return Promise.all([commentIssue(context, 
text.INACTIVE_ISSUE), closeIssue(context)]);
 
+case 'missing-demo':
+return Promise.all([
+commentIssue(context, replaceAt(text.MISSING_DEMO)),
+getRemoveLabel(context, 'waiting-for: community'),
+context.github.issues.addLabels(context.issue({
+labels: ['waiting-for: author']
+}))
+]);
+
 // case 'waiting-for: author':
 // return commentIssue(context, 
replaceAt(text.ISSUE_TAGGED_WAITING_AUTHOR));
 
@@ -66,9 +73,9 @@ module.exports = app => {
 const isCommenterAuthor = commenter === 
context.payload.issue.user.login;
 let removeLabel;
 let addLabel;
-if (coreCommitters.isCoreCommitter(commenter) && !isCommenterAuthor) {
+if (isCommitter(context.payload.comment.author_association)) {
 // New comment from core committers
-removeLabel = getRemoveLabel(context, 'waiting-for: help');
+removeLabel = getRemoveLabel(context, 'waiting-for: community');
 }
 else if (isCommenterAuthor) {
 // New comment from issue author
@@ -80,8 +87,7 @@ module.exports = app => {
 return Promise.all([removeLabel, addLabel]);
 });
 
-// Pull Requests Not Tested Yet
-app.on(['pull_request.opened', 'pull_request.reopened'], async context => {
+app.on(['pull_request.opened'], async context => {
 const auth = context.payload.pull_request.author_association;
 const comment = context.github.issues.createComment(context.issue({
 body: isCommitter(auth) ? text.PR_OPENED_BY_COMMITTER : 
text.PR_OPENED
@@ -95,8 +101,15 @@ module.exports = app => {
 labels: labelList
 }));
 
+return Promise.all([comment, addLabel]);
+});
+
+app.on(['pull_request.synchronize'], async context => {
+const addLabel = context.github.issues.addLabels(context.issue({
+labels: ['PR: awaiting review']
+}));
 const removeLabel = getRemoveLabel(context, 'PR: revision needed');
-return Promise.all([comment, addLabel, removeLabel]);
+return Promise.all([addLabel, removeLabel]);
 });
 
 app.on(['pull_request.closed'], async context => {
diff --git a/src/text.js b/src/text.js
index ab01a9a..3d20b05 100644
--- a/src/text.js
+++ b/src/text.js
@@ -39,6 +39,9 @@ AT_ISSUE_AUTHOR Would you like to debug it by yourself? This 
is a quicker way to
 
 Please have a look at [How to debug 
ECharts](https://github.com/apache/incubator-echarts/blob/master/CONTRIBUTING.md#how-to-debug-echarts)
 if you'd like to give a try. 邏`;
 
+const MISSING_DEMO =
+`AT_ISSUE_AUTHOR Please provide a demo for the issue either with 
https://jsfiddle.net/ovilia/n6xc4df3/ or 
https://gallery.echartsjs.com/editor.html.`;
+
 const ISSUE_TAGGED_PRIORITY_HIGH =
 `This issue is labeled with \`priority: high\`, which means it's a 
frequently asked problem and we will fix it ASAP.`;
 
@@ -76,6 +79,7 @@ module.exports = {
 NOT_USING_TEMPLATE,
 ISSUE_CREATED,
 ISSUE_UPDATED,
+MISSING_DEMO,
 INACTIVE_ISSUE,
 PR_OPENED,
 LABEL_HOWTO,


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



[incubator-echarts-bot] 20/32: feat: pr label

2020-10-27 Thread wangzx
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/incubator-echarts-bot.git

commit 27926dba30a77a7a07bb7123f62bcb1992199514
Author: Ovilia 
AuthorDate: Mon Feb 17 11:47:52 2020 +0800

feat: pr label
---
 index.js| 27 ---
 src/text.js |  4 
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index fe0422a..2c51d00 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,4 @@
 const Issue = require('./src/issue');
-const coreCommitters = require('./src/coreCommitters');
 const text = require('./src/text');
 
 module.exports = app => {
@@ -33,7 +32,6 @@ module.exports = app => {
 );
 };
 
-// console.log(context.payload);
 switch (context.payload.label.name) {
 case 'invalid':
 return Promise.all([commentIssue(context, 
text.NOT_USING_TEMPLATE), closeIssue(context)]);
@@ -44,6 +42,15 @@ module.exports = app => {
 case 'inactive':
 return Promise.all([commentIssue(context, 
text.INACTIVE_ISSUE), closeIssue(context)]);
 
+case 'missing-demo':
+return Promise.all([
+commentIssue(context, replaceAt(text.MISSING_DEMO)),
+getRemoveLabel(context, 'waiting-for: community'),
+context.github.issues.addLabels(context.issue({
+labels: ['waiting-for: author']
+}))
+]);
+
 // case 'waiting-for: author':
 // return commentIssue(context, 
replaceAt(text.ISSUE_TAGGED_WAITING_AUTHOR));
 
@@ -66,9 +73,9 @@ module.exports = app => {
 const isCommenterAuthor = commenter === 
context.payload.issue.user.login;
 let removeLabel;
 let addLabel;
-if (coreCommitters.isCoreCommitter(commenter) && !isCommenterAuthor) {
+if (isCommitter(context.payload.comment.author_association)) {
 // New comment from core committers
-removeLabel = getRemoveLabel(context, 'waiting-for: help');
+removeLabel = getRemoveLabel(context, 'waiting-for: community');
 }
 else if (isCommenterAuthor) {
 // New comment from issue author
@@ -80,8 +87,7 @@ module.exports = app => {
 return Promise.all([removeLabel, addLabel]);
 });
 
-// Pull Requests Not Tested Yet
-app.on(['pull_request.opened', 'pull_request.reopened'], async context => {
+app.on(['pull_request.opened'], async context => {
 const auth = context.payload.pull_request.author_association;
 const comment = context.github.issues.createComment(context.issue({
 body: isCommitter(auth) ? text.PR_OPENED_BY_COMMITTER : 
text.PR_OPENED
@@ -95,8 +101,15 @@ module.exports = app => {
 labels: labelList
 }));
 
+return Promise.all([comment, addLabel]);
+});
+
+app.on(['pull_request.synchronize'], async context => {
+const addLabel = context.github.issues.addLabels(context.issue({
+labels: ['PR: awaiting review']
+}));
 const removeLabel = getRemoveLabel(context, 'PR: revision needed');
-return Promise.all([comment, addLabel, removeLabel]);
+return Promise.all([addLabel, removeLabel]);
 });
 
 app.on(['pull_request.closed'], async context => {
diff --git a/src/text.js b/src/text.js
index ab01a9a..3d20b05 100644
--- a/src/text.js
+++ b/src/text.js
@@ -39,6 +39,9 @@ AT_ISSUE_AUTHOR Would you like to debug it by yourself? This 
is a quicker way to
 
 Please have a look at [How to debug 
ECharts](https://github.com/apache/incubator-echarts/blob/master/CONTRIBUTING.md#how-to-debug-echarts)
 if you'd like to give a try. 邏`;
 
+const MISSING_DEMO =
+`AT_ISSUE_AUTHOR Please provide a demo for the issue either with 
https://jsfiddle.net/ovilia/n6xc4df3/ or 
https://gallery.echartsjs.com/editor.html.`;
+
 const ISSUE_TAGGED_PRIORITY_HIGH =
 `This issue is labeled with \`priority: high\`, which means it's a 
frequently asked problem and we will fix it ASAP.`;
 
@@ -76,6 +79,7 @@ module.exports = {
 NOT_USING_TEMPLATE,
 ISSUE_CREATED,
 ISSUE_UPDATED,
+MISSING_DEMO,
 INACTIVE_ISSUE,
 PR_OPENED,
 LABEL_HOWTO,


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