22 lines
672 B
Bash
Executable File
22 lines
672 B
Bash
Executable File
#!/bin/bash
|
|
# pe-commit absolute file path
|
|
PRE_COMMIT_BIN="$(which pre-commit)"
|
|
|
|
# Check whether pre-commit is installed and executable
|
|
if [[ ! -x "${PRE_COMMIT_BIN}" ]]; then
|
|
printf "[$(tput setaf 1)$(tput bold)error$(tput sgr0)] %s\n" \
|
|
"pre-commit is not installed. Please use 'pip install pre-commit' to install."
|
|
exit 1
|
|
fi
|
|
|
|
# Updating pre-commit to ensure hooks in .pre-commit-config.yaml are found
|
|
"${PRE_COMMIT_BIN}" autoupdate
|
|
|
|
if ! "${PRE_COMMIT_BIN}" run --all-files; then
|
|
printf "[$(tput setaf 1)$(tput bold)error$(tput sgr0)] %s\n" \
|
|
"Linting failed please review above output and fix issues before committing."
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|