diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-02-09 17:46:16 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-02-09 17:48:06 +0900 |
commit | e65b48db3f9bc0fac67642305a3e73b86452e912 (patch) | |
tree | d2553b082815f46c84df65128eb4adb364b5e05a /code_format/git-hooks/remove-client-side-hooks | |
parent | 0e60f5c6834eb89dec4c62ab67d0a08a87a2ba77 (diff) | |
download | scripts-code-format/client-side-scripts.tar.gz scripts-code-format/client-side-scripts.zip |
Code format: add client side pre-commit hook and scriptscode-format/client-side-scripts
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'code_format/git-hooks/remove-client-side-hooks')
-rwxr-xr-x | code_format/git-hooks/remove-client-side-hooks | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/code_format/git-hooks/remove-client-side-hooks b/code_format/git-hooks/remove-client-side-hooks new file mode 100755 index 0000000..5d9bd9e --- /dev/null +++ b/code_format/git-hooks/remove-client-side-hooks @@ -0,0 +1,44 @@ +#!/bin/bash + +# Remove client side hooks from all TDE local repositories + +# Note: this is <tdehome>/scripts/code_format/git-hooks +SCRIPT_DIR=`dirname $(readlink -f "$0")` +TDE_DIR="${SCRIPT_DIR}/../../.." + +if [[ ! -f "${TDE_DIR}/.gitmodules" ]]; then + echo " --- Unable to find repository list (.gitmodules). Aborting." + exit 1 +fi + +sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <"${TDE_DIR}/.gitmodules" | \ +grep "^main/" | \ +while read MODULE; do + cd "${TDE_DIR}/${MODULE}" + GIT_COMMON_DIR=`git rev-parse --git-common-dir` + if [[ "${GIT_COMMON_DIR}" == ".git" ]]; then + # Normal repository + HOOK_DIR="${TDE_DIR}/${MODULE}/${GIT_COMMON_DIR}/hooks" + else + # Worktree repository + HOOK_DIR="${GIT_COMMON_DIR}/hooks" + fi + # Check hook folder exists + if [ ! -d "${HOOK_DIR}" ]; then + echo " --- Unable to find the hook folder for the repository ${MODULE}" + echo " Skipping module." + continue + fi + # Check whether the pre-commit hook exists + if [ ! -e "${HOOK_DIR}/pre-commit" ]; then + echo " --- Pre-commit hook not found for the repository ${MODULE}" + echo " Skipping module." + continue + fi + rm "${HOOK_DIR}/pre-commit" + if [ ! -e "${HOOK_DIR}/pre-commit" ]; then + echo "Pre-commit hook removed for the repository ${MODULE}" + else + echo " --- Something went wrong when removing the pre-commit hook for the repositoty ${MODULE}" + fi +done |