I am trying to add a pre-commit hook locally on my repository. I want to run a script only if a .tpl file has been modified/added/deleted in the commit. Is there an easy way to check this?
Thank you :-)
You probably need something like this:
#!/bin/bash
if git diff --name-only --cached | grep -Eq '\.tpl$'; then
# do your job
fi
The --procelain
flag guarantees that output won't change in future versions of git (they keep it consistent).