From 9793b05bf38a989fa648ca50365d015a7b0a301d Mon Sep 17 00:00:00 2001 From: cpojer Date: Wed, 23 Jan 2019 07:08:20 -0800 Subject: [PATCH] Friendlier Danger bot (#23124) Summary: Danger bot is pretty aggressive. This makes it a bit more friendly and helpful. See screenshot (this PR previously had an empty summary): screen shot 2019-01-23 at 14 23 32 [General] [Changed] Danger bot is now friendlier in the RN repo. Pull Request resolved: https://github.com/facebook/react-native/pull/23124 Differential Revision: D13782700 Pulled By: cpojer fbshipit-source-id: 51a86af9449df6fef798415bcb450c79d7cea16b --- bots/dangerfile.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/bots/dangerfile.js b/bots/dangerfile.js index 422f96042..7343dca05 100644 --- a/bots/dangerfile.js +++ b/bots/dangerfile.js @@ -14,7 +14,7 @@ const includes = require('lodash.includes'); const {danger, fail, warn} = require('danger'); // Fails if the description is too short. -if (!danger.github.pr.body || danger.github.pr.body.length < 10) { +if (!danger.github.pr.body || danger.github.pr.body.length < 50) { fail(':grey_question: This pull request needs a description.'); } @@ -34,7 +34,10 @@ const includesTestPlan = danger.github.pr.body.toLowerCase().includes('test plan'); if (!includesTestPlan) { const title = ':clipboard: Test Plan'; - const idea = 'This PR appears to be missing a Test Plan.'; + const idea = + 'This PR appears to be missing a Test Plan. ' + + 'Please add a section called "test plan" describing ' + + 'how to verify your changes are correct.'; warn(`${title} - ${idea}`); } @@ -47,11 +50,16 @@ const correctlyFormattedChangelog = changelogRegex.test(danger.github.pr.body); if (!includesChangelog) { const title = ':clipboard: Changelog'; - const idea = 'This PR appears to be missing Changelog.'; + const idea = + 'This PR appears to be missing Changelog. ' + + 'Please add a section called "changelog" and ' + + 'format it as explained in the [contributing guidelines](http://facebook.github.io/react-native/docs/contributing#changelog).'; warn(`${title} - ${idea}`); } else if (!correctlyFormattedChangelog) { const title = ':clipboard: Changelog'; - const idea = 'This PR may have incorrectly formatted Changelog.'; + const idea = + 'This PR may have incorrectly formatted Changelog. Please ' + + 'format it as explained in the [contributing guidelines](http://facebook.github.io/react-native/docs/contributing#changelog).'; warn(`${title} - ${idea}`); } @@ -59,8 +67,10 @@ if (!includesChangelog) { var bigPRThreshold = 600; if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { const title = ':exclamation: Big PR'; - const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger - .github.pr.additions + danger.github.pr.deletions} lines.`; + const idea = + `This PR is unlikely to get reviewed because it touches too many lines (${danger + .github.pr.additions + danger.github.pr.deletions}). ` + + 'Consider sending smaller Pull Requests and stack them on top of each other.'; warn(`${title} - ${idea}`); } else if ( danger.git.modified_files + @@ -69,10 +79,12 @@ if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { bigPRThreshold ) { const title = ':exclamation: Big PR'; - const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger - .git.modified_files + - danger.git.added_files + - danger.git.deleted_files} files.`; + const idea = + `This PR is unlikely to get reviewed because it touches too many files (${danger + .git.modified_files + + danger.git.added_files + + danger.git.deleted_files}). ` + + 'Consider sending smaller Pull Requests and stack them on top of each other.'; warn(`${title} - ${idea}`); }