forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add a commit-msg git hook to check commit messages (angular…
…#22969) The commit command will fail if the commit message header does not follow the Angular convetions as defined in /CONTRIBUTING.md. You can force the commit by adding the `--no-verify` option. NOTE: You should remove all unused hooks (in <angular>/.git/hooks) before running `yarn` so that husky hooks are installed correctly. PR Close angular#22969
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#! /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.') | ||
} | ||
} | ||
|
||
process.exit(isValid ? 0 : 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters