fix(dev-infra): use commit message validation from @angular/dev-infra-private (#36172)
Prior to this change we manage a local version of commit message validation in addition to the commit message validation tool contained in the ng-dev tooling. By adding the ability to validate a range of commit messages together, the remaining piece of commit message validation that is in the local version is replicated. We use both commands provided by the `ng-dev commit-message` tooling: - pre-commit-validate: Set to automatically run on an git hook to validate commits as they are created locally. - validate-range: Run by CI for every PR, testing that all of the commits added by the PR are valid when considered together. Ensuring that all fixups are matched to another commit in the change. PR Close #36172
This commit is contained in:

committed by
Kara Erickson

parent
4894220acf
commit
61db817eed
@ -1,34 +0,0 @@
|
||||
#! /usr/bin/env node
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
// git commit-msg hook to check the commit message against Angular conventions
|
||||
// see `/CONTRIBUTING.md` for mode details.
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const checkMsg = require('../../tools/validate-commit-message');
|
||||
const msgFile = process.env['GIT_PARAMS'];
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (msgFile) {
|
||||
const commitMsg = fs.readFileSync(msgFile, {encoding: 'utf-8'});
|
||||
const firstLine = commitMsg.split('\n')[0];
|
||||
isValid = checkMsg(firstLine);
|
||||
|
||||
if (!isValid) {
|
||||
console.error(
|
||||
'\nCheck CONTRIBUTING.md at the root of the repo for more information.' +
|
||||
'\n' +
|
||||
'\n(In case you need the invalid commit message, it should be stored in \'.git/COMMIT_EDITMSG\'.)');
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(isValid ? 0 : 1);
|
Reference in New Issue
Block a user