Version Dependencies Build Status Coverage Code Climate

GitHooks

Some usefull git hooks, it's written on ruby but can be used for other languages.

Installation

Add this line to your application's Gemfile:

gem 'git-hooks'

And then execute:

$ bundle

Or install it yourself as:

$ gem install git-hooks

Usage

Install git_hooks on your project.

$ cd /path/to/project
$ git_hooks install pre-commit [--force]

Create configuration file

Create a .git_hooks.yml on project root.

$ cd /path/to/project
$ git_hooks init

By now you will find the following built-in hooks:

  • Prevent commits on master branch.
  • Prevent commits with rubocop offenses.
  • Prevent commits with broken rspec tests.
  • Prevent commits with debugger.
  • Prevent commits with trailing white space.

Ensure hooks existence

To ensure that hooks exists on .git/hooks, include this line

GitHooks.validate_hooks!

on your application's start up (e.g. config/environments/development.rb or config/environments/test.rb for a rails app).

This will force git_hooks installation before your application's start.

Contributing

  1. Fork it ( https://github.com/stupied4ever/ruby-git-hooks/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request