Skip to content

Instantly share code, notes, and snippets.

@llekn llekn/.overcommit.yml forked from gmq/.overcommit.yml
Last active Nov 2, 2018

Embed
What would you like to do?
Overcommit configuration for rails/es6 projects
# Use this file to configure the Overcommit hooks you wish to use. This will
# extend the default configuration defined in:
# https://github.com/brigade/overcommit/blob/master/config/default.yml
#
# At the topmost level of this YAML file is a key representing type of hook
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
# customize each hook, such as whether to only run it on certain files (via
# `include`), whether to only display output if it fails (via `quiet`), etc.
#
# For a complete list of hooks, see:
# https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
#
# For a complete list of options that you can use to customize hooks, see:
# https://github.com/brigade/overcommit#configuration
#
# Global overcommit settings
gemfile: false
verify_signatures: true
# Commit messages checks
CommitMsg:
CapitalizedSubject:
enabled: false
MessageFormat:
enabled: true
pattern: '^((feat|fix|docs|style|refactor|perf|test|chore)\((.+)\): (.+))'
expected_pattern_message: '<type>(<scope>): <subject>'
sample_message: 'feat(app): add very important sidebar'
on_fail: fail
PreCommit:
ALL:
problem_on_unmodified_line: ignore
exclude:
- 'public/**/*'
- 'bower_components/**/*'
- 'node_modules/**/*'
- 'vendor/**/*'
- 'tmp/**/*'
RuboCop:
enabled: true
EsLint:
enabled: true
# PostCheckout:
# BundleInstall:
# enabled: true
# PrePush:
# RSpec:
# enabled: true
# command: ['bundle', 'exec', 'rspec']

Overcommit

Overview

Overcommit is a gem that makes easy to add, configure and run tasks on git hooks (script that are run when manipulating a git repo, for example, before making a commit).

Setup

  1. Add the gem overcommit to development environment, or install it globally on you machine with gem install overcommit
  2. On the project on which you want to use overcommit, install the git hooks provided by overcommit: overcommit --install
  3. Configure overcommit to run the tasks that you want by editing the .overcommit.yml faile.
  4. As a security measure, each time that you make changes to the .overcommit.yml file or to the git hook you need to "sign" the configuration again (to prevent running malicious scripts that could be added in a remote commit). So, as last step you have to run overcommit --sign

Configuration

A minimal .overcommit.yml config file that only runs rubocop before a commit looks like:

PreCommit:
 RuboCop:
   enabled: true
   on_warn: fail

A very nice overcommit configuration that runs rubocop and eslint can be found at: https://gist.github.com/llekn/b64231949f1e3e0463b90d6a5b828e08#file-overcommit-yml

For a complete list of available hooks you can check https://github.com/brigade/overcommit#built-in-hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.