D8 - hooks
src: Pluralsight, Timothy Ghanim
hooks
automated scripts that are triggered when certain git actions occur
- types of hooks:
- pre-: called before the git command executes; can abort the git command
- post-: called after the git command executes; doesn't affect the git command
- misc: called while the git command executes; can abort the git command

image: Pluralsight, Timothy Ghanim
-
in the above example, a commit workflow is demonstrated
-
note that the first three hooks (pre and two misc hooks) abort the workflow if they fail, but the final one (post) does not
-
hooks can be written in any language - git just needs an executable to run
-
command line argument, input, output and error streams, and environment variables are used to receive results from the hook
-
it checks for the exit code to determine success or failure
-
hooks are neutral to the IDE
-
they run in the same repo
| client-side | server-side |
|---|---|
| - easily disables by removing them or using git switched | - easily disabled by removing them |
| - easily forgotten | - cannot be bypassed by client |
| - for dev's productivity and defensive style | - to enforce server-side policy |