Skip to content

Commit

Permalink
[IMP] config: Add leftover debugger/console check in pre-commit hook
Browse files Browse the repository at this point in the history
This will prevent people from pushing debug statements by mistake.
The hook includes an override as debug statements are sometimes required
(e.g. inside the compiler and its related tests).

closes odoo/o-spreadsheet#1420

X-original-commit: cb1076b773c8e85b238f08337d21439e9d67a9ab
Signed-off-by: Pierre Rousseau (pro) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
Topdev97 committed Jun 10, 2022
1 parent 1fca21e commit 17c9463
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# ativate user inputs
exec < /dev/tty

if [ "$HUSKY_PRE_COMMIT" != 0 ]; then
npx lint-staged

consoleregexp='console\.|debugger'

# CHECK
if test $(git diff --cached | grep -nE $consoleregexp | wc -l) != 0
then
exec git diff --cached --color | grep -nE $consoleregexp -A 2 -B 2
read -p "There are some occurrences of forbidden patterns at your modification. Are you sure want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
exit 0; #THE USER WANTS TO CONTINUE
else
exit 1; # THE USER DONT WANT TO CONTINUE SO ROLLBACK
fi
fi
fi

0 comments on commit 17c9463

Please sign in to comment.