[envs] move python hook detection to envs.zsh

This commit is contained in:
odrling 2024-04-10 10:09:58 +02:00
parent 21d50e89f8
commit 54451a841c
No known key found for this signature in database
GPG key ID: EC907F69A27A90C5
2 changed files with 10 additions and 20 deletions

View file

@ -106,7 +106,7 @@ odr-load-python-venv() {
return 1
fi
[ -f ~/.zsh/envs/python ] && source ~/.zsh/envs/python
odr-detect-python-hooks
}
odr-display-hooks() {
@ -115,6 +115,15 @@ odr-display-hooks() {
git config --get-regexp odrhooks\. 2>/dev/null
}
odr-detect-python-hooks() {
local possible_hooks=(ruff isort black pyright)
local hooks=()
for hook in ${possible_hooks[@]}; do
grep $hook pyproject.toml &>/dev/null && odr-add-detected-hooks $hook
done
}
odr-add-detected-hooks() {
for name in "${@}"; do
[ "$(git config odrhooks.${name})" != 1 ] && DETECTED_HOOKS+=("${name}")

View file

@ -1,19 +0,0 @@
# -----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <florianbadie@odrling.xyz> wrote this file. As long as you retain this notice
# you can do whatever you want with this stuff. If we meet some day, and you
# think this stuff is worth it, you can buy me a beer in return. odrling
# -----------------------------------------------------------------------------
# shellcheck shell=bash
{
local possible_hooks=(ruff isort black pyright)
local hooks=()
for hook in ${possible_hooks[@]}; do
grep $hook pyproject.toml &>/dev/null && odr-add-detected-hooks $hook
done
DETECTED_HOOKS+="${hooks[@]}"
}