diff --git a/lib/process-issue-comment.js b/lib/process-issue-comment.js index b0c4c836..73360cd5 100644 --- a/lib/process-issue-comment.js +++ b/lib/process-issue-comment.js @@ -25,6 +25,8 @@ async function processIssueComment({ context, commentReply }) { return; } + let pullCreated = false; + for (var contributor in contributors) { const who = contributor; const contributions = contributors[who]; @@ -45,7 +47,7 @@ async function processIssueComment({ context, commentReply }) { success: false, }); - await triggerActionAdd( + pullCreated ||= await triggerActionAdd( context, commentReply, log, @@ -54,6 +56,13 @@ async function processIssueComment({ context, commentReply }) { branchName ); } + + if (!pullCreated) { + commentReply.reply( + `I couldn't determine any contributions to add, did you specify any contributions? + Please make sure to use [valid contribution names](https://allcontributors.org/docs/en/emoji-key).` + ); + } } async function triggerActionAdd( @@ -65,12 +74,8 @@ async function triggerActionAdd( branchName ) { if (contributions.length === 0) { - log.info("No contributions"); - commentReply.reply( - `I couldn't determine any contributions to add, did you specify any contributions? - Please make sure to use [valid contribution names](https://allcontributors.org/docs/en/emoji-key).` - ); - return; + log.info(`No contributions for ${who}`); + return false; } // set up repository instance. Uses branch if it exists, falls back to repository's default branch @@ -100,17 +105,17 @@ async function triggerActionAdd( }, `${who} already have ${contributions.join(", ")}` ); - return; + } else { + log.info( + { + pullCreated, + success: true, + createdFor: user.id, + createdForType: "user", + createdForLogin: user.login.toLowerCase(), + }, + `${who} added for ${contributions.join(", ")}` + ); } - - log.info( - { - pullCreated, - success: true, - createdFor: user.id, - createdForType: "user", - createdForLogin: user.login.toLowerCase(), - }, - `${who} added for ${contributions.join(", ")}` - ); + return true; } diff --git a/test/fixtures/issue_comment.created.json b/test/fixtures/issue_comment.created.json index 09749e2c..75c6ffea 100644 --- a/test/fixtures/issue_comment.created.json +++ b/test/fixtures/issue_comment.created.json @@ -79,7 +79,7 @@ "created_at": "2019-01-10T08:36:52Z", "updated_at": "2019-01-10T08:36:52Z", "author_association": "MEMBER", - "body": "@all-contributors please add jakebolam for code, doc and infra" + "body": "@all-contributors please add jakebolam for code, doc and infra\nšŸ¤– Beep boop! This comment was added automatically by [all-contributors-auto-action](https://github.com/marketplace/actions/all-contributors-auto-action).\nNot all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.\n...and of course, thank you for contributing! šŸ’™" }, "repository": { "id": 164268911,