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/03/08 01:40:29 UTC

[echarts-bot] branch master updated: feat: label first-time contributor.

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 ff43707  feat: label first-time contributor.
ff43707 is described below

commit ff437072df8865dc2f4bbd2dfa0b2f4264f915f0
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Mon Mar 8 09:39:20 2021 +0800

    feat: label first-time contributor.
---
 index.js | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/index.js b/index.js
index 95ea299..457729a 100644
--- a/index.js
+++ b/index.js
@@ -119,12 +119,17 @@ module.exports = (app) => {
         if (isCore) {
             labelList.push('PR: author is committer');
         }
+
         const content = context.payload.pull_request.body;
         if (content && content.indexOf('[x] The API has been changed.') > -1) {
             labelList.push('PR: awaiting doc');
             commentText += '\n\n' + text.PR_AWAITING_DOC;
         }
 
+        if (await isFirstTimeContributor(context)) {
+            labelList.push('PR: first-time contributor');
+        }
+
         const comment = context.octokit.issues.createComment(
             context.issue({
                 body: commentText
@@ -234,6 +239,22 @@ function commentIssue(context, commentText) {
     );
 }
 
+async function isFirstTimeContributor (context) {
+    try {
+        const response = await context.octokit.issues.listForRepo(
+            context.repo({
+                state: 'all',
+                creator: context.payload.pull_request.user.login
+            })
+        );
+        return response.data.filter(data => data.pull_request) === 1;
+    }
+    catch (e) {
+        logger.error('failed to check first-time contributor');
+        logger.error(e);
+    }
+}
+
 async function translateIssue (context, createdIssue) {
     if (!createdIssue) {
         return;


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