Created
March 20, 2024 22:15
-
-
Save david206/8f7cdfa5546cd95020c407cb0825641d to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
REPO_DIR="/path/to/your/repositories" | |
configure_pre_commit() { | |
repo_path="$1" | |
cd "$repo_path" || return 1 | |
if ! command -v pre-commit &> /dev/null; then | |
echo "pre-commit is not installed. Installing..." | |
pip install pre-commit | |
fi | |
# Initialize pre-commit in the repository | |
pre-commit install | |
# Create or update the .pre-commit-config.yaml file | |
cat <<EOF > .pre-commit-config.yaml | |
repos: | |
- repo: https://github.com/pre-commit/pre-commit-hooks | |
rev: v2.4.0 | |
hooks: | |
- id: no-commit-to-branch | |
EOF | |
echo "Pre-commit configured for $repo_path" | |
} | |
for repo_path in "$REPO_DIR"/*/; do | |
echo "Configuring pre-commit for $repo_path" | |
configure_pre_commit "$repo_path" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment