diff --git a/dev-infra/commit-message/validate.spec.ts b/dev-infra/commit-message/validate.spec.ts index 98b877b212..0d92bdccb2 100644 --- a/dev-infra/commit-message/validate.spec.ts +++ b/dev-infra/commit-message/validate.spec.ts @@ -23,6 +23,7 @@ const config: {commitMessage: CommitMessageConfig} = { 'compiler', 'core', 'packaging', + '@angular-devkit/build-angular', ] } }; @@ -87,6 +88,11 @@ describe('validate-commit-message.js', () => { [`'weird' is not an allowed type.\n => TYPES: ${TYPES}`]); }); + it('should pass when scope contains NPM scope', () => { + expectValidationResult( + validateCommitMessage('fix(@angular-devkit/build-angular): something'), true); + }); + it('should fail when scope is invalid', () => { const errorMessageFor = (scope: string, header: string) => `'${scope}' is not an allowed scope.\n => SCOPES: ${SCOPES}`; diff --git a/dev-infra/commit-message/validate.ts b/dev-infra/commit-message/validate.ts index 7f41c10c4b..4b630f7a7d 100644 --- a/dev-infra/commit-message/validate.ts +++ b/dev-infra/commit-message/validate.ts @@ -116,9 +116,10 @@ export function validateCommitMessage( return false; } - if (commit.scope && !config.scopes.includes(commit.scope)) { + const fullScope = commit.npmScope ? `${commit.npmScope}/${commit.scope}` : commit.scope; + if (fullScope && !config.scopes.includes(fullScope)) { errors.push( - `'${commit.scope}' is not an allowed scope.\n => SCOPES: ${config.scopes.join(', ')}`); + `'${fullScope}' is not an allowed scope.\n => SCOPES: ${config.scopes.join(', ')}`); return false; } diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index e70c96f3b1..333d75bf6c 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -1871,8 +1871,9 @@ function validateCommitMessage(commitMsg, options = {}) { errors.push(`Scopes are required for commits with type '${commit.type}', but no scope was provided.`); return false; } - if (commit.scope && !config.scopes.includes(commit.scope)) { - errors.push(`'${commit.scope}' is not an allowed scope.\n => SCOPES: ${config.scopes.join(', ')}`); + const fullScope = commit.npmScope ? `${commit.npmScope}/${commit.scope}` : commit.scope; + if (fullScope && !config.scopes.includes(fullScope)) { + errors.push(`'${fullScope}' is not an allowed scope.\n => SCOPES: ${config.scopes.join(', ')}`); return false; } // Commits with the type of `release` do not require a commit body.