Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Overcommit Overcommit will run checks against any staged code and commit messages before allowing the code to be committed or pushed. This example .overcommit.yml file follows what I've tended to use on past projects. It's opt-in by running the `overcommit --install` command, and can always be disabled or overridden if needed. For an example of how it works, make one of the yaml configuration files invalid and try to commit it. * Add comments and a note to the readme * Fix a regex typo * Add bin/setup-osx script
- Loading branch information
Showing
7 changed files
with
229 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
module Overcommit::Hook::PreCommit | ||
class InternalAddresses < Base | ||
def run | ||
errors = [] | ||
unparsable = [] | ||
|
||
applicable_files.each do |file| | ||
begin | ||
contents = File.read(file) | ||
errors << "#{file}: Includes 10.X.Y.Z address" if contents =~ /10\.\d+\.\d+\.\d+/ | ||
errors << "#{file}: Includes vaww address" if contents =~ /vaww\./ | ||
rescue | ||
unparsable << "Could not match against #{file}" | ||
end | ||
end | ||
|
||
return :fail, errors.join("\n") if errors.any? | ||
|
||
:pass | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
PreCommit: | ||
# Check if local Gemfile.lock matches Gemfile when either changes, unless | ||
# Gemfile.lock is ignored by git. | ||
BundleCheck: | ||
enabled: true | ||
|
||
# Warns if any TODO or FIXMEs are added. | ||
FixMe: | ||
enabled: true | ||
|
||
# Disallows commits on these branches. Always work in a branch! | ||
ForbiddenBranches: | ||
enabled: true | ||
branch_patterns: | ||
- 'master' | ||
- 'production' | ||
- 'release-*' | ||
|
||
# Disallow local filesystem paths in the Gemfile | ||
LocalPathsInGemfile: | ||
enabled: true | ||
|
||
# Check for internal VA addresses in new commits | ||
InternalAddresses: | ||
enabled: true | ||
|
||
# Re-run rubocop before allowing a commit to cut down on 'lint fix' commits | ||
RuboCop: | ||
enabled: true | ||
on_warn: fail # Treat all warnings as failures | ||
command: ['bundle', 'exec', 'rubocop'] | ||
exclude: | ||
- 'Gemfile' | ||
|
||
# Warn on trailing whitespace, which Rubocop may also catch. | ||
TrailingWhitespace: | ||
enabled: true | ||
exclude: | ||
- '**/db/structure.sql' # Ignore trailing whitespace in generated files | ||
- '**/*.yml' | ||
- '**/*.yml.example' | ||
- '**/*.md' | ||
|
||
# Ensures YAMLs are valid | ||
YamlSyntax: | ||
enabled: true | ||
|
||
PrePush: | ||
# Prevents destructive updates to specified branches. | ||
ProtectedBranches: | ||
enabled: true | ||
branch_patterns: | ||
- 'master' | ||
- 'production' | ||
- 'release-*' | ||
|
||
# Re-run Brakeman before pushing, as it's quick. | ||
Brakeman: | ||
enabled: true | ||
command: ['bundle', 'exec', 'brakeman'] | ||
|
||
PostCheckout: | ||
ALL: | ||
quiet: true | ||
|
||
# Run `bundle install` if the Gemfile or Gemfile lock change during a checkout | ||
BundleInstall: | ||
enabled: true | ||
quiet: false | ||
|
||
PostRewrite: | ||
# Run `bundle install` if the Gemfile or Gemfile lock change during a checkout | ||
BundleInstall: | ||
enabled: true | ||
quiet: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.