feat(dev-infra): prevent pr merges of features or breaking changes on rc (#41660)

Prevent pull requests targeting `target: rc` from merging PRs with breaking
changes or features from being merged.

PR Close #41660
This commit is contained in:
Joey Perrott 2021-04-16 08:40:54 -07:00 committed by Andrew Kushnir
parent 62e3f3279d
commit 83d6a96163
2 changed files with 12 additions and 12 deletions

View File

@ -3614,23 +3614,23 @@ function assertChangesAllowForTargetLabel(commits, label, config) {
var exemptedScopes = config.targetLabelExemptScopes || [];
/** List of commits which are subject to content requirements for the target label. */
commits = commits.filter(function (commit) { return !exemptedScopes.includes(commit.scope); });
var hasBreakingChanges = commits.some(function (commit) { return commit.breakingChanges.length !== 0; });
var hasFeatureCommits = commits.some(function (commit) { return commit.type === 'feat'; });
switch (label.pattern) {
case 'target: major':
break;
case 'target: minor':
// Check if any commits in the pull request contains a breaking change.
if (commits.some(function (commit) { return commit.breakingChanges.length !== 0; })) {
if (hasBreakingChanges) {
throw PullRequestFailure.hasBreakingChanges(label);
}
break;
case 'target: rc':
case 'target: patch':
case 'target: lts':
// Check if any commits in the pull request contains a breaking change.
if (commits.some(function (commit) { return commit.breakingChanges.length !== 0; })) {
if (hasBreakingChanges) {
throw PullRequestFailure.hasBreakingChanges(label);
}
// Check if any commits in the pull request contains a commit type of "feat".
if (commits.some(function (commit) { return commit.type === 'feat'; })) {
if (hasFeatureCommits) {
throw PullRequestFailure.hasFeatureCommits(label);
}
break;

View File

@ -200,23 +200,23 @@ function assertChangesAllowForTargetLabel(
const exemptedScopes = config.targetLabelExemptScopes || [];
/** List of commits which are subject to content requirements for the target label. */
commits = commits.filter(commit => !exemptedScopes.includes(commit.scope));
const hasBreakingChanges = commits.some(commit => commit.breakingChanges.length !== 0);
const hasFeatureCommits = commits.some(commit => commit.type === 'feat');
switch (label.pattern) {
case 'target: major':
break;
case 'target: minor':
// Check if any commits in the pull request contains a breaking change.
if (commits.some(commit => commit.breakingChanges.length !== 0)) {
if (hasBreakingChanges) {
throw PullRequestFailure.hasBreakingChanges(label);
}
break;
case 'target: rc':
case 'target: patch':
case 'target: lts':
// Check if any commits in the pull request contains a breaking change.
if (commits.some(commit => commit.breakingChanges.length !== 0)) {
if (hasBreakingChanges) {
throw PullRequestFailure.hasBreakingChanges(label);
}
// Check if any commits in the pull request contains a commit type of "feat".
if (commits.some(commit => commit.type === 'feat')) {
if (hasFeatureCommits) {
throw PullRequestFailure.hasFeatureCommits(label);
}
break;