Last active
June 5, 2023 14:25
-
-
Save guibeira/69e7a5d35a7a2cfb56c748b732d0aedc to your computer and use it in GitHub Desktop.
Pre commit on work folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repos: | |
- repo: https://github.com/jumanjihouse/pre-commit-hooks | |
rev: master | |
hooks: | |
- id: forbid-space-in-indent | |
types: [python] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# start templated | |
ARGS=(hook-impl --config="$HOME"/gitglobalhooks/.pre-commit-config.yaml --hook-type=pre-commit) | |
# end templated | |
HERE="$(cd "$(dirname "$0")" && pwd)" | |
# run only on mashgin projects folder | |
LOCAL_EXE=$(pwd) | |
ARGS+=(--hook-dir "$HERE" -- "$@") | |
if [ -e ./.git/hooks/pre-commit ]; then | |
echo "pre-commit already installed" | |
./.git/hooks/pre-commit "$@" | |
elif [[ $LOCAL_EXE == *$COMPANY_FOLDER_NAME* ]] ; then | |
echo "Running ${COMPANY_FOLDER_NAME} rules." | |
exec pre-commit "${ARGS[@]}" | |
else | |
echo "Not a ${COMPANY_FOLDER_NAME} project." | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put the company name folder on your bashrc/zshrc
create a folder
copy both files for this folder
On your git config