How can I make my git hook that only runs my unit tests when there are changes to .py files.
Asked
Active
Viewed 308 times
0
-
2git has no idea how you want to classify the files it's tracking, if you want to do this the logic would have to be *in the hook*. If you want to know which files were modified in a pre-commit hook, for example, see e.g. https://stackoverflow.com/q/2412450/3001761. – jonrsharpe Mar 08 '19 at 09:59
-
Question was badly worded, have edited. – Stuart Axon Mar 08 '19 at 11:15
-
Do you want to run your tests before commit, or before push? – Ignacio Catalina Mar 09 '19 at 11:17
-
Before push sounds like a good option since they take a while to run. – Stuart Axon Mar 11 '19 at 10:25
-
The first comment has information on how to code a script to get the changed files. Then you need to specialize that code to look only for your desired files. After that you need to use that script as your hook, keeping in mind that hooks SHOULD return exit(0) or exit(1) (0=sucess, 1=failure) to allow or abort the push in your case. – Lovato Apr 27 '19 at 00:21