portfolio/githooks/pre-commit
christiangoeschel d6b2a3e6d9
All checks were successful
Pull Request Checks / commit-message-check (pull_request) Successful in 6s
Pull Request Checks / linting (pull_request) Successful in 1m58s
feat: Add a CI pipeline and fix all code style issues
2025-02-27 00:08:41 -05:00

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