MarcSerraPeralta / py-package-template

Template for creating a python package repository
MIT License
0 stars 0 forks source link

git hooks? #1

Open MarcSerraPeralta opened 3 months ago

MarcSerraPeralta commented 3 months ago

It could be interesting to understand the usefulness of git hooks:

Hooks are programs you can place in a hooks directory to trigger actions at certain points in git’s execution. Hooks that don’t have the executable bit set are ignored.

from https://git-scm.com/docs/githooks

This was brought to my attention when watching this Youtube video (at 4:11min)

MarcSerraPeralta commented 2 months ago

This ref has a nice description of local and server git hooks.

From this stackoverflow post, it seems that a better way to store the git hooks in a repo is:

Nowadays you can do the following to set a directory that is under version control to be your Git hooks directory, e.g., MY_REPO_DIR/.githooks would be git config --local core.hooksPath .githooks/ It is still not directly enforceable but, if you add a note in your README (or whatever), this requires a minimum of effort on each developer's part.

One of the drawback that I see is if one needs to rapidly merge a hotfix, because maybe it does not fulfill pass the git hook (e.g. imagine that the pre-push runs the tests locally). However, this could be solved by checking if the name of the branch starts with hotfix...