-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
34 lines (25 loc) · 952 Bytes
/
setup.sh
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
33
34
#!/usr/bin/env bash
# Variables
REPO_URL="https://raw.githubusercontent.com/shan-shaji/flutter-pre-commit-hook-script"
GITHOOKS_DIR=".githooks"
PRE_COMMIT_FILE="flutter_lint_check.sh"
TARGET_HOOK="$GITHOOKS_DIR/pre-commit"
echo "Downloading pre-commit hook from GitHub..."
curl -O "$REPO_URL/refs/heads/main/$PRE_COMMIT_FILE"
if [ ! -f "$PRE_COMMIT_FILE" ]; then
echo "Error: Failed to download $PRE_COMMIT_FILE from GitHub."
exit 1
fi
if [ ! -d "$GITHOOKS_DIR" ]; then
echo "Creating .githooks directory..."
mkdir "$GITHOOKS_DIR"
else
echo ".githooks directory already exists."
fi
echo "Moving flutter_lint_check.sh to .githooks and renaming to pre-commit..."
mv "$PRE_COMMIT_FILE" "$TARGET_HOOK"
echo "Making the pre-commit hook executable..."
chmod +x "$TARGET_HOOK"
echo "Configuring git to use the .githooks folder for hooks..."
git config core.hooksPath "$GITHOOKS_DIR"
echo "Pre-commit hook successfully installed!"