Skip to content

Instantly share code, notes, and snippets.

@chalkygames123
Last active August 14, 2022 08:42
Show Gist options
  • Save chalkygames123/5e5eee367f390d824aab3977f4ee28a5 to your computer and use it in GitHub Desktop.
Save chalkygames123/5e5eee367f390d824aab3977f4ee28a5 to your computer and use it in GitHub Desktop.
Git hook for appending "git-notify:" to the commit message when specific files are changed
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
COMMIT_MSG_FILE=$1
STAGED_FILES=$(git diff --cached --name-only)
PATTERN='package-lock.json'
MESSAGE='Please rerun `npm install`'
if echo "$STAGED_FILES" | grep --quiet --line-regexp --max-count 1 "$PATTERN"; then
echo "\n\ngit-notify: $MESSAGE" >> $COMMIT_MSG_FILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment