Skip to content

Commit

Permalink
fix(ng-dev/pr): do not fail assertions for changes for target label w…
Browse files Browse the repository at this point in the history
…hen the fixup label is applied (#392)

As noted in #301, if the commit message fixup label is applied we cannot properly assert
whether or not the changes are allowed for the target label.  Instead we should skip this
assertion.

Fixes #301

PR Close #392
  • Loading branch information
josephperrott committed Feb 8, 2022
1 parent ea10bc1 commit 1c1d5c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ng-dev/pr/common/targeting/target-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export async function getTargetBranchesForPullRequest(
);
const targetBranches = await getBranchesFromTargetLabel(matchingLabel, githubTargetBranch);

assertChangesAllowForTargetLabel(commits, matchingLabel, config.pullRequest, releaseTrains);
assertChangesAllowForTargetLabel(
commits,
matchingLabel,
config.pullRequest,
releaseTrains,
labelsOnPullRequest,
);

return targetBranches;
} catch (error) {
Expand Down
14 changes: 13 additions & 1 deletion ng-dev/pr/common/validation/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Commit} from '../../../commit-message/parse';
import {TargetLabel, TargetLabelName} from '../targeting/target-label';
import {breakingChangeLabel, PullRequestConfig} from '../../config';
import {PullRequestFailure} from './failures';
import {red, warn} from '../../../utils/console';
import {debug, red, warn} from '../../../utils/console';
import {
getStatusesForPullRequest,
PullRequestFromGithub,
Expand All @@ -28,7 +28,19 @@ export function assertChangesAllowForTargetLabel(
label: TargetLabel,
config: PullRequestConfig,
releaseTrains: ActiveReleaseTrains,
labelsOnPullRequest: string[],
) {
if (
!!config.commitMessageFixupLabel &&
labelsOnPullRequest.some((name) => matchesPattern(name, config.commitMessageFixupLabel))
) {
debug(
'Skipping commit message target label validation because the commit message fixup label is ' +
'applied.',
);
return;
}

/**
* List of commit scopes which are exempted from target label content requirements. i.e. no `feat`
* scopes in patch branches, no breaking changes in minor or patch changes.
Expand Down

0 comments on commit 1c1d5c5

Please sign in to comment.