Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
Last active January 12, 2020 18:45
Show Gist options
  • Save wshihadeh/65989d75f43198c85d8ba2fdc45a6cea to your computer and use it in GitHub Desktop.
Save wshihadeh/65989d75f43198c85d8ba2fdc45a6cea to your computer and use it in GitHub Desktop.
Overcommit Configurations
gemfile: false
# Where to store hook plugins specific to a repository. These are loaded in
# addition to the default hooks Overcommit comes with. The location is relative
# to the root of the repository.
plugin_directory: '.git-hooks'
# Whether to hide hook output by default. This results in completely silent hook
# runs except in the case of warning or failure.
quiet: false
# Number of hooks that can be run concurrently. Typically this won't need to be
# adjusted, but if you know that some of your hooks themselves use multiple
# processors you can lower this value accordingly. You can define
# single-operator mathematical expressions, e.g. '%{processors} * 2', or
# '%{processors} / 2'.
concurrency: '%{processors}'
# Whether to check if a hook plugin has changed since Overcommit last ran it.
# This is a defense mechanism when working with repositories which can contain
# untrusted code (e.g. when you fetch a pull request from a third party).
# See https://github.com/brigade/overcommit#security for more information.
verify_signatures: true
# # Hooks that run after HEAD changes or a file is explicitly checked out.
PostCheckout:
ALL:
required: false
quiet: false
skip_file_checkout: true
BundleInstall:
enabled: true
description: 'Install Bundler dependencies'
requires_files: true
required_executable: 'bundle'
install_command: 'gem install bundler'
flags: ['install']
include:
- 'Gemfile'
- 'Gemfile.lock'
- '*.gemspec'
# Hooks that are run against every commit message after a user has written it.
# These hooks are useful for enforcing policies on commit messages written for a
# project.
CommitMsg:
ALL:
requires_files: false
quiet: false
EmptyMessage:
enabled: true
description: 'Check for empty commit message'
TextWidth:
enabled: true
description: 'Check text width'
max_subject_width: 60
min_subject_width: 0
max_body_width: 72
CapitalizedSubject:
enabled: true
description: 'Check subject capitalization'
on_warn: fail
SingleLineSubject:
enabled: true
description: 'Check subject line'
TrailingPeriod:
enabled: true
description: 'Check for trailing periods in subject'
required: true
on_warn: fail
MessageFormat:
enabled: true
description: 'Check commit message matches expected pattern'
pattern: 'Close #(.+)[|](.+)'
expected_pattern_message: 'Close #<Issue Id> | <Commit Message Description>'
sample_message: 'Close #DEFECT-1234 | Refactored Onboarding flow'
on_warn: fail
SpellCheck:
enabled: true
description: 'Check for misspelled words'
required_executable: 'hunspell'
flags: ['-a']
PreCommit:
ALL:
problem_on_unmodified_line: report
requires_files: true
required: true
quiet: false
on_warn: fail
AuthorEmail:
enabled: true
description: 'Check author email'
requires_files: false
pattern: '^[^@][email protected]'
AuthorName:
enabled: true
description: 'Check for author name'
requires_files: false
BrokenSymlinks:
enabled: true
description: 'Check for broken symlinks'
quiet: true
BundleAudit:
enabled: true
description: 'Check for vulnerable versions of gems'
required_executable: 'bundle-audit'
install_command: 'gem install bundler-audit'
BundleOutdated:
enabled: true
description: 'List installed gems with newer versions available'
required_executable: 'bundle'
flags: ['outdated', '--strict', '--parseable']
install_command: 'gem install bundler'
CaseConflicts:
enabled: true
description: 'Check for case-insensitivity conflicts'
ExecutePermissions:
enabled: true
description: 'Check for file execute permissions'
quiet: false
required: true
FixMe:
enabled: true
description: 'Check for "token" strings'
required_executable: 'grep'
flags: ['-IEHnw']
keywords: ['BROKEN', 'BUG', 'ERROR', 'FIXME', 'HACK', 'NOTE', 'OPTIMIZE', 'REVIEW', 'TODO', 'WTF', 'XXX']
exclude:
- '.overcommit.yml'
FileSize:
enabled: true
description: 'Check for oversized files'
size_limit_bytes: 1_000_000
ForbiddenBranches:
enabled: true
description: 'Check for commit to forbidden branch'
quiet: true
branch_patterns: ['master']
MergeConflicts:
enabled: true
description: 'Check for merge conflicts'
quiet: true
required_executable: 'grep'
flags: ['-IHn', "^<<<<<<<[ \t]"]
RailsBestPractices:
enabled: true
description: 'Analyze with RailsBestPractices'
required_executable: 'rails_best_practices'
flags: ['--without-color']
install_command: 'gem install rails_best_practices'
RailsSchemaUpToDate:
enabled: true
description: 'Check if database schema is up to date'
include:
- 'db/migrate/*.rb'
- 'db/schema.rb'
- 'db/structure.sql'
Reek:
enabled: true
description: 'Analyze with Reek'
required_executable: 'reek'
flags: ['--single-line', '--no-color', '--force-exclusion']
install_command: 'gem install reek'
include:
- '**/*.gemspec'
- '**/*.rake'
- '**/*.rb'
- '**/Gemfile'
- '**/Rakefile'
RuboCop:
enabled: true
quiet: false
description: 'Analyze with RuboCop'
required_executable: 'rubocop'
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
install_command: 'gem install rubocop'
include:
- '**/*.gemspec'
- '**/*.rake'
- '**/*.rb'
- '**/*.ru'
- '**/Gemfile'
- '**/Rakefile'
RubySyntax:
enabled: true
description: 'Check ruby syntax'
required_executable: 'ruby'
command: [
'ruby',
'-e',
'ARGV.each { |applicable_file| ruby_c_output = `ruby -c #{applicable_file}`; puts ruby_c_output unless $?.success? }'
]
include:
- '**/*.gemspec'
- '**/*.rb'
# # Hooks that run during `git push`, after remote refs have been updated but
# # before any objects have been transferred.
PrePush:
ALL:
requires_files: false
required: false
quiet: false
RSpec:
enabled: true
description: 'Run RSpec test suite'
required_executable: 'rspec'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment