How to config git hook for detecting exactly selected folder (exem /../../schemas) and exactly selected file extension (exem *.xsd)?
Asked
Active
Viewed 29 times
0
-
What exaclty should your hook do? What have you tried? – Christoph May 11 '18 at 10:24
-
I want just get name of changed file and author name. I want to automatically send email with this info to smbd. But I'll deal with sending email myself =) – Slava Podolskiy May 11 '18 at 10:29
1 Answers
2
You can run git diff
to see all changes and grep results by the pattern you like. Like this
all_changes=$(git diff --cached --find-copies --find-renames --name-only --diff-filter=ACR)
only_xsd_files=$(echo $all_changes | grep "\.xsd")
only_schemas=$(echo $only_xsd_files | grep "path/to/schemas")
And then you can run rest of your script

Moti Korets
- 3,738
- 2
- 26
- 35