enable pre-commit
This commit is contained in:
45
dot_git-template/.pre-commit-config.yaml
Normal file
45
dot_git-template/.pre-commit-config.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.4.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- id: check-merge-conflict
|
||||
- id: pretty-format-json
|
||||
- id: check-symlinks
|
||||
- id: detect-aws-credentials
|
||||
- id: detect-private-key
|
||||
- id: flake8
|
||||
- id: requirements-txt-fixer
|
||||
- id: sort-simple-yaml
|
||||
- repo: git://github.com/antonbabenko/pre-commit-terraform
|
||||
rev: v1.25.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
|
||||
hooks:
|
||||
- id: terraform_fmt
|
||||
- id: terraform_docs
|
||||
- id: terraform_tflint
|
||||
args: ['--deep']
|
||||
- id: terraform_validate
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
sha: 1.11.2
|
||||
hooks:
|
||||
- id: shellcheck
|
||||
- id: shfmt
|
||||
- id: script-must-have-extension
|
||||
- id: git-check
|
||||
# - id: git-dirty
|
||||
- id: forbid-binary
|
||||
- id: bundler-audit
|
||||
#- repo: https://github.com/ansible/ansible-lint.git
|
||||
# rev: v4.1.0
|
||||
# hooks:
|
||||
# - id: ansible-lint
|
||||
# files: \.(yaml|yml)$
|
||||
#- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||
# rev: 'v1.5' # Use the sha / tag you want to point at
|
||||
# hooks:
|
||||
# - id: autopep8
|
44
dot_git-template/hooks/pre-commit
Executable file
44
dot_git-template/hooks/pre-commit
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
# File generated by pre-commit: https://pre-commit.com
|
||||
# ID: 138fd403232d2ddd5efb44317e38bf03
|
||||
import os
|
||||
import sys
|
||||
|
||||
# we try our best, but the shebang of this script is difficult to determine:
|
||||
# - macos doesn't ship with python3
|
||||
# - windows executables are almost always `python.exe`
|
||||
# therefore we continue to support python2 for this small script
|
||||
if sys.version_info < (3, 3):
|
||||
from distutils.spawn import find_executable as which
|
||||
else:
|
||||
from shutil import which
|
||||
|
||||
# work around https://github.com/Homebrew/homebrew-core/issues/30445
|
||||
os.environ.pop('__PYVENV_LAUNCHER__', None)
|
||||
|
||||
# start templated
|
||||
INSTALL_PYTHON = '/usr/local/Cellar/pre-commit/2.0.1/libexec/bin/python3.8'
|
||||
ARGS = ['hook-impl', '--config=.pre-commit-config.yaml', '--hook-type=pre-commit', '--skip-on-missing-config']
|
||||
# end templated
|
||||
ARGS.extend(('--hook-dir', os.path.realpath(os.path.dirname(__file__))))
|
||||
ARGS.append('--')
|
||||
ARGS.extend(sys.argv[1:])
|
||||
|
||||
DNE = '`pre-commit` not found. Did you forget to activate your virtualenv?'
|
||||
if os.access(INSTALL_PYTHON, os.X_OK):
|
||||
CMD = [INSTALL_PYTHON, '-mpre_commit']
|
||||
elif which('pre-commit'):
|
||||
CMD = ['pre-commit']
|
||||
else:
|
||||
raise SystemExit(DNE)
|
||||
|
||||
CMD.extend(ARGS)
|
||||
if sys.platform == 'win32': # https://bugs.python.org/issue19124
|
||||
import subprocess
|
||||
|
||||
if sys.version_info < (3, 7): # https://bugs.python.org/issue25942
|
||||
raise SystemExit(subprocess.Popen(CMD).wait())
|
||||
else:
|
||||
raise SystemExit(subprocess.call(CMD))
|
||||
else:
|
||||
os.execvp(CMD[0], CMD)
|
Reference in New Issue
Block a user