[envs] move python hook detection to envs.zsh
This commit is contained in:
parent
21d50e89f8
commit
54451a841c
|
@ -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}")
|
||||
|
|
|
@ -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[@]}"
|
||||
}
|
Loading…
Reference in a new issue