gezpage / git_template

A project for storing git hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A set of useful git hooks

These hooks automate some tasks with the help of git.

Installation

git clone git@github.com:greg0ire/git_template.git ~/.git_template

Configuration

Set the newly cloned repo as your git template directory. This will tell git to populate new repositories created with either git clone or git init with the content of this directory. By default, it uses /usr/share/git-core/templates.

git config --global init.templatedir '~/.git_template'

What's inside ?

For the moment, mostly hooks related to tools from the php ecosystem.

Exuberant Ctags hook

Updates .git/tags file by scanning the project with the ctags command. It is configured for a php project. To make vim look for this file in the .git directory, you can install Tim Pope's fugitive or simply add set tags+=.git/tags to your .vimrc - some plugins (like ctrlp-tjump) require this to see the tags even if fugitive is installed.

Exuberant Ctags hook (patched ctags version)

Same as above but uses a patched version of ctags with improved PHP language support. Only use one of the ctags hooks at a time.

Composer hook

This set of scripts monitor composer.lock changes and updates your vendor dependencies when appropriate. It assumes Composer is globally installed.

Sismo hook

The post-commit hook makes Sismo run each time you commit. Make sure you configure the environment variables in your hooksrc properly. It is a post-commit hook because Sismo is a local Continuous Testing Server, which means you can build before you push.

Doctrine hook

This hooks runs the doctrine:schema:validate task of a Symfony project and updates / migrates your database depending on the presence of a doctrine-migrations folder in your vendor directory.

Junk checker hook

Checks for user defined phrases that you don't want to commit to your repository, such as var_dump(), console.log() etc.

This can be overridden by doing a:

git commit --no-verify

This hook is language-agnostic.

Usage

Start by creating your hooksrc file:

mv .git/hooks/hooksrc.sample .git/hooks/hookrc

Then edit it to add plugins you wish to activate. The sample file contains the ctags and composer hooks by default.

Contributing

Creating your php plugin is as easy as creating a php folder under hooks/php. You can then create hooks in it. For the moment, only the following are supported (because I'm lazy)

  • post-commit
  • post-checkout
  • post-merge
  • post-rewrite

If you need to add configuration variables in the hooksrc, you need to prefix them with the path to your hook, which is obviously unique. This will avoid variable names collisions.

Source

Inspired by Tim Pope

About

A project for storing git hooks

License:GNU General Public License v3.0


Languages

Language:Shell 87.4%Language:Racket 12.6%