This script automates the installation of Python, pre-commit, and a specific pre-commit hook (check-yaml
by default). The script can be configured to enable or disable the specified hook using git config
. Additionally, it provides the option to be installed via the "curl ... | sh" method.
To install the script using the "curl ... | sh" method, run the following command in your terminal:
curl -fsSL https://raw.githubusercontent.com/LawRider/gitleaks-pre-commit-hook/hook.sh | sh
The script can be configured using git config to enable or disable the specified pre-commit hook.
Enable the Hook:
git config --global hooks.check-yaml.enable true
Disable the Hook:
git config --global hooks.check-yaml.enable false
The script will automatically detect whether Python is installed. If not, it will install Python based on your operating system.
If the specified pre-commit hook is enabled, the script will download pre-commit and configure the specified hook in the .pre-commit-config.yaml file. It will then install pre-commit and clean up temporary files.
If you've installed the script via "curl ... | sh" and want to remove the script after installation, the script will clean up itself. You don't need to manually remove it.
Make sure you have internet access during the installation process. The script is designed to be self-contained and cleans up after installation.
curl -fsSL https://raw.githubusercontent.com/LawRider/gitleaks-pre-commit-hook/hook.sh | sh
git config --global hooks.check-yaml.enable true
./hook.sh
git config --global hooks.check-yaml.enable false