🎓 https://learngitbranching.js.org/
🔫🦶 🧔♂️⁉️
commit, merge-commit, push, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, post-rewrite, and manual
pip install pre-commit
pre-commit --version
cd /path/al/repositorio/git/a/configurar
# git init
pre-commit sample-config # Crea un .pre-commit-config.yaml de ejemplo
vim .pre-commit # Configurar
pre-commit install # Fácil de poner
pre-commit uninstall # Fácil de sacar
.pre-commit-config.yaml
default_install_hook_types: # En que git hooks llamamos a pre-commit
- commit-msg
- pre-commit
default_stages: # Cuales git hooks usamos implícitamente en los repos
- commit
- manual
fail_fast: true # Parar al primer fallo
exclude: LICENSE|CHANGELOG.md|\.gitlab/ # Ficheros a no comprobar
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.3.0
hooks:
- id: check-merge-conflict # Detecta merge conflict strings
- id: end-of-file-fixer # El fichero acaba en un enter
- id: mixed-line-ending # Enters crlf/lf reemplaza por el mayoritario
- id: trailing-whitespace # Borra los espacios al final de línea
args:
- --markdown-linebreak-ext=md # Excepto en markdown (hard linebreaks)
pre-commit help
usage: pre-commit [-h] [-V] {autoupdate,clean,gc,init-templatedir,install,install-hooks,migrate-config,run,sample-config,try-repo,uninstall,validate-config,validate-manifest,help,hook-impl} ...
positional arguments:
{autoupdate,clean,gc,init-templatedir,install,install-hooks,migrate-config,run,sample-config,try-repo,uninstall,validate-config,validate-manifest,help,hook-impl}
...
pre-commit autoupdate # Auto-update pre-commit config to the latest repos' versions.
pre-commit run --all-files # Run hooks on all files
Listados en https://pre-commit.com/hooks.html
repos:
- repo: 'https://github.com/commitizen-tools/commitizen'
rev: v2.37.0
hooks:
- id: commitizen
stages:
- commit-msg
repos:
- repo: 'https://github.com/PyCQA/isort'
rev: 5.10.1
hooks:
- id: isort
args:
- --profile
- black
- --filter-files
language_version: python3
- repo: 'https://github.com/psf/black'
rev: 22.10.0
hooks:
- id: black
repos:
- repo: meta # https://pre-commit.com/#meta-hooks
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.3.0
hooks:
# Identify invalid files
- id: check-ast
- id: check-yaml
- id: check-json
- id: check-toml
# Git checks
- id: check-added-large-files
- id: detect-private-key
- id: check-case-conflict
# Python check
- id: check-docstring-first
- id: debug-statements
- id: requirements-txt-fixer
- id: fix-byte-order-marker
# General quality checks
- id: check-executables-have-shebangs
repos:
- repo: 'https://github.com/asottile/pyupgrade'
rev: v3.2.2
hooks:
- id: pyupgrade
args:
- --py37-plus
repos:
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args:
- --max-line-length=89
- --ignore=E203,E266,E501,W503,F403,F401
repos:
- repo: 'https://github.com/jendrikseipp/vulture'
rev: v2.6
hooks:
- id: vulture
# entry: python scripts/run_vulture.py
pass_filenames: false
require_serial: true