GithubHelp home page GithubHelp logo

futoase / pre-commit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jish/pre-commit

0.0 1.0 0.0 64 KB

A slightly improved pre-commit hook for git

Home Page: http://jish.github.com/pre-commit/

pre-commit's Introduction

A better pre-commit hook for git.

Current versionย  Build status

Installation

Install the gem

$ gem install pre-commit

Use the pre-commit command to generate a stub pre-commit hook

# In your git repo
$ pre-commit install

This creates a .git/hooks/pre-commit script which will check your git config and run checks that are enabled.

Configuration

These are the available checks:

  • white_space
  • console_log
  • debugger
  • pry
  • tabs
  • jshint
  • js_lint
  • closure_syntax_check
  • php (Runs php -l on all staged files)
  • rspec_focus (Will check if you are about to check in a :focus in a spec file)
  • ruby_symbol_hashrockets (1.9 syntax. BAD :foo => "bar". GOOD foo: "bar")
  • local (executes config/pre-commit.rb with list of changed files)
  • merge_conflict (Will check if you are about to check in a merge conflict)
  • migrations (Will make sure you check in the proper files after creating a Rails migration)
  • ci (Will run the pre_commit:ci rake task and pass or fail accordingly)
  • rubocop (Check ruby code style using the rubocop gem. Rubocop must be installed)

To configure which checks you would like to run, simply set the pre-commit.checks git configuration setting.

To enable white_space and tab checks:

# From your git repo
$ git config "pre-commit.checks" "white_space, tabs"

To enable white_space, console_log and debugger checks:

# From your git repo
$ git config "pre-commit.checks" "white_space, console_log, debugger"

Note: If no checks are configured, a default set of checks is run:

white_space, console_log, debugger, pry, tabs, jshint, migrations, merge_conflict, local

For the rubocop check, you can tell it what config file to use by setting a path relative to the repo:

# From your git repo
$ git config "pre-commit.rubocop.config" "config/rubocop.yml"

pre-commit's People

Contributors

jish avatar grosser avatar shajith avatar mnzaki avatar bquorning avatar jamesbarnett avatar deviantintegral avatar zzet avatar darrenboyd avatar carhartl avatar mikz avatar mikedfunk avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.