2021-11-02 05:53:27 -05:00
|
|
|
|
#!/bin/sh
|
2022-04-29 08:01:02 -05:00
|
|
|
|
|
2023-08-17 04:56:52 -05:00
|
|
|
|
# Catch devs who have installed lefthook, went back into the past and reinstalled husky,
|
|
|
|
|
# then came back into lefthook-land.
|
|
|
|
|
if [ -f ".git/hooks/pre-commit" ]; then
|
|
|
|
|
if grep -q lefthook ".git/hooks/pre-commit"; then
|
|
|
|
|
# Remove husky from their git config
|
|
|
|
|
env SILENT=1 ./scripts/cleanup-husky.sh
|
2022-04-29 08:01:02 -05:00
|
|
|
|
|
2023-08-17 04:56:52 -05:00
|
|
|
|
# And run the lefthook precommit hook instead of this
|
|
|
|
|
./.git/hooks/pre-commit "$@"
|
|
|
|
|
exit $?
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2021-11-02 05:53:27 -05:00
|
|
|
|
|
2023-08-17 04:56:52 -05:00
|
|
|
|
# This precommit hook exists only for people who still have hooksPath=.husky in their git config
|
|
|
|
|
# from when we used husky. This is intended to run only on first commit after pulling the lefthook changes.
|
|
|
|
|
#
|
|
|
|
|
# Either setting up lefthook, or running the clean command will unset the hooksPath git config so this
|
|
|
|
|
# hook is no longer ran when committing.
|
|
|
|
|
|
2023-08-18 08:10:18 -05:00
|
|
|
|
echo "\n⚠️⚠️⚠️ Important: Pre-commit hooks are now opt-in. ⚠️⚠️⚠️"
|
2023-08-17 04:56:52 -05:00
|
|
|
|
echo "To install the new pre-commit hooks:"
|
2023-08-18 08:10:18 -05:00
|
|
|
|
echo " $ make lefthook-install"
|
2023-08-17 04:56:52 -05:00
|
|
|
|
echo "Or, silence this message by cleaning up the old hooks"
|
2023-08-18 08:10:18 -05:00
|
|
|
|
echo " $ make cleanup-old-git-hooks"
|
2023-08-17 04:56:52 -05:00
|
|
|
|
echo "\nPre-commit hooks will not run on this commit and it will be committed even if it contains lint errors."
|
|
|
|
|
echo "See https://github.com/grafana/grafana/blob/main/contribute/developer-guide.md#configure-precommit-hooks for more info\n"
|
|
|
|
|
|
|
|
|
|
exit 0
|