-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.sh
More file actions
executable file
·32 lines (24 loc) · 1018 Bytes
/
main.sh
File metadata and controls
executable file
·32 lines (24 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Display a message indicating this script is running
echo "Running global pre-commit hooks setup...."
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Path to install_dependencies.sh
INSTALL_DEPENDENCIES="$SCRIPT_DIR/install_dependencies.sh"
# Install necessary dependencies
if [ -f "$INSTALL_DEPENDENCIES" ]; then
echo "Installing dependencies..."
source "$INSTALL_DEPENDENCIES"
else
echo "[!] Error: $INSTALL_DEPENDENCIES not found. Skipping dependency install."
fi
# Set up Git hooks
TEMPLATE_DIR="$HOME/.git-templates/hooks"
mkdir -p "$TEMPLATE_DIR"
# cp global/commit-msg.sh "$TEMPLATE_DIR/commit-msg"
cp global/pre-commit.sh "$TEMPLATE_DIR/pre-commit"
cp global/commit-msg.sh "$TEMPLATE_DIR/commit-msg"
chmod +x "$TEMPLATE_DIR/pre-commit" "$TEMPLATE_DIR/commit-msg"
## automatically enabling pre-commit on repositories
git config --global init.templateDir "$HOME/.git-templates"
echo "Git hooks set up successfully!"