#!/bin/sh # block committing the bot/monitor configured in development mode # # the deployed branch must always run in production. this rejects any staged # python that sets DEVELOPMENT_MODE = DevelopmentMode.DEVELOPMENT. keep # DEVELOPMENT in your working tree while developing, just don't stage that line. # # activate once per clone: git config core.hooksPath .githooks pattern='^[[:space:]]*DEVELOPMENT_MODE[[:space:]]*=[[:space:]]*DevelopmentMode\.DEVELOPMENT\b' offenders="" for file in $(git diff --cached --name-only --diff-filter=d -- '*.py'); do if git show ":$file" | grep -qE "$pattern"; then offenders="$offenders $file" fi done if [ -n "$offenders" ]; then echo "pre-commit: refusing to commit DEVELOPMENT mode in:$offenders" >&2 echo " set DEVELOPMENT_MODE = DevelopmentMode.PRODUCTION before committing," >&2 echo " or 'git restore --staged ' to leave it out of this commit." >&2 exit 1 fi exit 0