From fab36648ec07d3ef9038e5d8ab5e3d53a8ead382 Mon Sep 17 00:00:00 2001 From: Hypnosphi Date: Mon, 5 Mar 2018 02:27:02 +0300 Subject: [PATCH] Feature-freeze master --- dangerfile.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/dangerfile.js b/dangerfile.js index 6b8c437802cf..d463743b5b57 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -1,17 +1,37 @@ import { fail, danger } from 'danger'; -import { flatten, intersection, isEmpty, includes } from 'lodash'; +import { flatten, intersection, isEmpty } from 'lodash'; const pkg = require('./package.json'); // eslint-disable-line import/newline-after-import const prLogConfig = pkg['pr-log']; +const Versions = { + PATCH: 'PATCH', + MINOR: 'MINOR', + MAJOR: 'MAJOR', +}; + +const branchVersion = Versions.PATCH; + const checkRequiredLabels = labels => { + const forbiddenLabels = flatten([ + 'do not merge', + 'in progress', + branchVersion !== Versions.MAJOR ? 'BREAKING CHANGE' : [], + branchVersion === Versions.PATCH ? 'feature request' : [], + ]); + const requiredLabels = flatten([ prLogConfig.skipLabels || [], Object.keys(prLogConfig.validLabels || {}), ]); - if (includes(labels, 'do not merge')) { - fail('PR is marked with "do not merge" label.'); + const blockingLabels = intersection(forbiddenLabels, labels); + if (!isEmpty(blockingLabels)) { + fail( + `PR is marked with ${blockingLabels.map(label => `"${label}"`).join(', ')} label${ + blockingLabels.length > 1 ? 's' : '' + }.` + ); } const foundLabels = intersection(requiredLabels, labels);