/git-hooks

Personal set of git hooks to automate mundane tasks

Primary LanguageShellMIT LicenseMIT

git-hooks

A personal set of git hooks to automate mundane tasks.

Setting up

Post Git 2.9

If you are using Git 2.9 you can clone this repository, set your core.hooksPath variable and you'll be good to go:

mkdir --parents "${HOME}/.config/git"
git config --global core.hooksPath "${HOME}/.config/git/hooks"
git clone https://github.com/AlexandreCarlton/git-hooks.git "${HOME}/.config/git/hooks"

Pre Git 2.9

If you aren't using a new enough version of Git, you'll have to clone this repository into your templates directory, which will be copied into every git repository you create. The downside of this is that you will have to manually update each repository's hooks when you update this one.

mkdir --parents "${HOME}/.config/git/templates"
git config --global init.templatedir "${HOME}/.config/git/templates"
git clone https://github.com/AlexandreCarlton/git-hooks.git "${HOME}/.config/git/templates/hooks"

If you would like to use these hooks in existing repositories, you will have to call git init in every single one, which will copy the template directory across into each .git folder.

Scripts

These are called by our git hooks.

clean-python-bytecode-files

Deletes any .pyc, .pyo and __pycache__ files found in the project to force recompilation of .py files on a checkout.

create-tags-file

"Adapted" from Effortless Ctags with Git, this script will create a tags file from all tracked files in the repository.

insert-jira-ticket

Attempts to determine the ticket number of a JIRA issue from the current branch name (generated by Bitbucket Server) and substitutes it into a special expression in the message template if present.

The syntax is:

  {{.*TICKET.*}}

where characters before and after 'TICKET' are preserved. For example, {{[TICKET] }} for ISSUE-123 would translate to [ISSUE-123] . If no ticket can be extracted, the expressions are removed.