Lint automatically with hooks

Follow the steps to create a pre-commit hook

  1. Create the file pre-commit inside the path .git/hooks/ of your local repository with this content:

#!/bin/bash

ROOT_DIR="$(git rev-parse --show-toplevel)"

echo "Running Flake8"
flake8 ${ROOT_DIR} --statistics
  1. Assign it execution permission

$ chmod +x .git/hooks/pre-commit

Last updated