mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-07 21:33:54 +00:00
build(hooks): add Commitizen hook
This change adds Commitizen, an interactive tool for writing commit messages, to the package.json file. This installs Commitizen within the `node_modules` directory automatically when developers invoke `npm install` from the root repository directory. Additionally, this change adds a prepare-commit-msg Git hook which invokes Commitizen prior to generation of the default commit message. It may be exited with the standard ^C signal without terminating the commit process for those who desperately want to avoid using it, but otherwise should encourage developers to conform to the new commit style without running into post-commit linting errors. Change-Id: I8a1e268ed40b61af38519d13d62b116fce76a494 Signed-off-by: Chris Kay <chris.kay@arm.com>
This commit is contained in:
parent
4b7eee81e3
commit
c75ce067aa
5 changed files with 4912 additions and 0 deletions
5
.cz.json
Normal file
5
.cz.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"path": "./node_modules/cz-conventional-changelog",
|
||||
"maxHeaderWidth": 50,
|
||||
"maxLineWidth": 72
|
||||
}
|
6
.husky/prepare-commit-msg
Executable file
6
.husky/prepare-commit-msg
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# shellcheck source=./_/husky.sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
"$(dirname "$0")/prepare-commit-msg.cz" "$@"
|
28
.husky/prepare-commit-msg.cz
Executable file
28
.husky/prepare-commit-msg.cz
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
file="$1"
|
||||
type="$2"
|
||||
|
||||
if [ -z "$type" ]; then # only run on new commits
|
||||
#
|
||||
# Save any commit message trailers generated by Git.
|
||||
#
|
||||
|
||||
trailers=$(git interpret-trailers --parse "$file")
|
||||
|
||||
#
|
||||
# Execute the Commitizen hook.
|
||||
#
|
||||
|
||||
(exec < "/dev/tty" && npx --no-install git-cz --hook) || true
|
||||
|
||||
#
|
||||
# Restore any trailers that Commitizen might have overwritten.
|
||||
#
|
||||
|
||||
printf "\n" >> "$file"
|
||||
|
||||
while IFS= read -r trailer; do
|
||||
git interpret-trailers --in-place --trailer "$trailer" "$file"
|
||||
done <<< "$trailers"
|
||||
fi
|
4871
package-lock.json
generated
4871
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,8 @@
|
|||
"postinstall": "husky install"
|
||||
},
|
||||
"devDependencies": {
|
||||
"commitizen": "^4.2.2",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"husky": "^5.0.4"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue