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):

<img width="785" alt="screen shot 2019-01-23 at 14 23 32" src="https://user-images.githubusercontent.com/13352/51613007-84416600-1f1a-11e9-88fc-6788f7854d89.png">

[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
This commit is contained in:
cpojer
2019-01-23 07:08:20 -08:00
committed by Facebook Github Bot
parent 9968d0c203
commit 9793b05bf3

View File

@@ -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} - <i>${idea}</i>`);
}
@@ -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} - <i>${idea}</i>`);
} 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} - <i>${idea}</i>`);
}
@@ -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} - <i>${idea}</i>`);
} 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} - <i>${idea}</i>`);
}