Skip to content

Commit

Permalink
Merge pull request #3149 from storybooks/feature-freeze
Browse files Browse the repository at this point in the history
Feature-freeze master
  • Loading branch information
Hypnosphi authored Mar 13, 2018
2 parents 9fe4db9 + 0aec277 commit 1046c08
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 1046c08

Please sign in to comment.