This project uses Git hooks to prevent sensitive information leaks and check commit messages. After cloning the code for the first time, please follow these steps to install the hooks:
Execute the following command to install all necessary Git hooks with one click:
./.git-hooks/install-hooks.shAfter installation, the following features will be enabled:
- Sensitive Information Detection (Based on Gitleaks)
-
Detect sensitive information such as API keys and tokens in the code
-
Block code submissions containing sensitive information
- Commit Message Inspection
-
Detect and block commit messages containing Chinese characters
-
Ensure commit messages use only English
If the automatic installation fails, you can manually follow these steps:
- Install pre-commit:
pip install pre-commit
- Install the pre-commit hook:
pre-commit install
- Install the commit-msg hook:
pre-commit install --hook-type commit-msg cp .git-hooks/check-commit-message.sh .git/hooks/commit-msg chmod +x .git/hooks/commit-msg
Q: How to temporarily skip hook checks?
A: In special cases, you can use the --no-verify parameter to skip checks:
git commit -m "Your commit message" --no-verify
However, use this parameter with caution to avoid leaking sensitive information.
Q: How to allow Chinese content in specific files?
A: Modify the allowlist section in the .gitleaks.toml file and add the corresponding file paths.
Q: Getting a "Chinese characters detected" prompt when committing?
A: Commit messages must not contain Chinese characters. Please write commit messages in English only.