Previously, the pre-commit hook was modified to disallow commiting when the config files were not up to date, the paths that were checked for changes assumed that the hook was executed in the community repo which breaks in enterprise and disallows commiting completely instead. This commit fixes that, and also reloads or refreshes the tooling automatically when it is not up to date before running prettier and eslint instead of aborting the commit and asking the user to do it by hand. closes odoo/odoo#97404 Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
19 lines
897 B
Bash
Executable File
19 lines
897 B
Bash
Executable File
#!/bin/bash
|
|
# run tooling only on branches that start with master to avoid linting noise in stable
|
|
if [[ $(git branch --show-current) == master* ]]; then
|
|
tooling_dir=$(cd -- "$(dirname "$0")" &> /dev/null && cd .. && pwd)
|
|
if ! cmp -s -- "$tooling_dir/_package.json" package.json; then
|
|
echo "Your package.json is out of date, reloading the tooling using the reload script"
|
|
"$tooling_dir/reload.sh"
|
|
elif
|
|
! cmp -s -- "$tooling_dir/_eslintignore" .eslintignore ||
|
|
! cmp -s -- "$tooling_dir/_prettierignore" .prettierignore ||
|
|
! cmp -s -- "$tooling_dir/_eslintrc.json" .eslintrc.json ||
|
|
! cmp -s -- "$tooling_dir/_prettierrc.json" .prettierrc.json
|
|
then
|
|
echo "Some of your eslint/prettier config files are out of date, refreshing them using the refresh script"
|
|
"$tooling_dir/refresh.sh"
|
|
fi
|
|
npm run format-staged
|
|
fi
|