feat(dev-infra): create commit-message validation script/tooling (#36117)

PR Close #36117
This commit is contained in:
Joey Perrott
2020-03-10 10:29:44 -07:00
committed by Misko Hevery
parent 989dea7083
commit 6fc85073d2
9 changed files with 503 additions and 6 deletions

View File

@ -6,7 +6,11 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {readFileSync} from 'fs';
import {join} from 'path';
import {verify} from './pullapprove/verify';
import {validateCommitMessage} from './commit-message/validate';
import {getRepoBaseDir} from './utils/config';
const args = process.argv.slice(2);
@ -16,6 +20,12 @@ switch (args[0]) {
case 'pullapprove:verify':
verify();
break;
case 'commit-message:pre-commit-validate':
const commitMessage = readFileSync(join(getRepoBaseDir(), '.git/COMMIT_EDITMSG'), 'utf8');
if (validateCommitMessage(commitMessage)) {
console.info('√ Valid commit message');
}
break;
default:
console.info('No commands were matched');
}