Skip to content

Instantly share code, notes, and snippets.

@leite08
Created February 27, 2023 16:55
Show Gist options
  • Save leite08/f1c3131d348d5f3d1e92981c0e4361a1 to your computer and use it in GitHub Desktop.
Save leite08/f1c3131d348d5f3d1e92981c0e4361a1 to your computer and use it in GitHub Desktop.
Husky git hook to notify about changes on files/folders upon merge
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# Place this on ./husky and make sure the file is executable (chmod 770 post-merge)
changed() {
git diff --name-only HEAD@{1} HEAD | grep "$1" > /dev/null 2>&1
}
echo "Checking updates on <file-type> files..."
if changed 'folder/file' || changed 'folder/file'; then
echo " "
echo "⚠ One or more change on <file-type> files. <anything-that-should-be-done?>
echo " "
else
echo "No updates detected on <file-type> files."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment