Last active
August 14, 2022 08:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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