Skip to content

Latest commit

 

History

History
 
 

git_hooks

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

GIT client hooks

From the client, you can execute any combination of shell commands before or after specific GIT commands are executed. On each project you can have different scripts which are located at folder .git/hooks/. Check this folder for samples.

For more information see:

Hook pre-commit

With this hook we can execute shell commands before a git commit. If the script exits with 0 (success) the commit will be performed and if it exits with 1 (error) it won't.

In this implementation:

  • we want to perform the commit only after the units tests have been passed
  • it also stops the commit if we are working directly with the develop or master branches

Hook pre-push

With this hook we can execute shell commands before a git push. If the script exits with 0 (success) the push will be performed and if it exits with 1 (error) it won't.

In this implementation:

  • if we are working with the branches develop or master we want to perform the push only after the integration tests have been passed

Installation instructions

  1. Copy the sample files to the project folder .git/hooks/
  2. Remove the .sample.sh suffix
  3. Make files executables with command chmod +x <filename>
  4. Change the PYTHON variable in all files to use your Phyton environment