From 54451a841cb8986a7d2d023b478df9d7e89e6ac3 Mon Sep 17 00:00:00 2001 From: odrling Date: Wed, 10 Apr 2024 10:09:58 +0200 Subject: [PATCH] [envs] move python hook detection to envs.zsh --- .zsh/envs.zsh | 11 ++++++++++- .zsh/envs/python | 19 ------------------- 2 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 .zsh/envs/python diff --git a/.zsh/envs.zsh b/.zsh/envs.zsh index 0e8478b..8d64588 100644 --- a/.zsh/envs.zsh +++ b/.zsh/envs.zsh @@ -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}") diff --git a/.zsh/envs/python b/.zsh/envs/python deleted file mode 100644 index 38812e0..0000000 --- a/.zsh/envs/python +++ /dev/null @@ -1,19 +0,0 @@ -# ----------------------------------------------------------------------------- -# "THE BEER-WARE LICENSE" (Revision 42): -# 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[@]}" -}