Files
odoo_source/addons/web/tooling/hooks/pre-commit
T
Samuel Degueldre b099b0cb35 [IMP] web: tooling: abort commit if tooling is outdated
Currently, if your tooling is not up to date, the pre-commit hook will
happily just format your code with the outdated config. This is
undesirable because the next person to touch the file with an up-to-date
config will introduce a bunch of linting noice in their commit.

This commit adds some basic checking by comparing the config files and
aborting the commit if they are out of date, and suggesting a refresh
when the eslint/prettier config files have changed or a full reload if
the package.json has changed.

closes odoo/odoo#97286

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-08-02 11:49:17 +02:00

19 lines
807 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
if ! cmp -s -- addons/web/tooling/_package.json package.json; then
echo "Your package.json is out of date, reload the tooling using the reload script"
exit 1
fi
if
! cmp -s -- addons/web/tooling/_eslintignore .eslintignore ||
! cmp -s -- addons/web/tooling/_prettierignore .prettierignore ||
! cmp -s -- addons/web/tooling/_eslintrc.json .eslintrc.json ||
! cmp -s -- addons/web/tooling/_prettierrc.json .prettierrc.json
then
echo "Some of your eslint/prettier config files are out of date, refresh them using the refresh script"
exit 1
fi
npm run format-staged
fi