forked from dominant-strategies/go-quai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-hooks.sh
executable file
·37 lines (30 loc) · 939 Bytes
/
install-hooks.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
35
36
#!/bin/bash
# Change to the root directory of your project
cd $(git rev-parse --show-toplevel)
# Symlink the pre-commit hook
ln -sf $(pwd)/hooks/pre-commit .git/hooks/pre-commit
# Detect the operating system
OS="$(uname)"
# Check if golangci-lint is installed, and install it if necessary
if ! command -v golangci-lint >/dev/null 2>&1; then
echo "golangci-lint not found. Installing..."
case $OS in
Linux)
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
;;
Darwin)
# Install or upgrade golangci-lint for macOS
if brew ls --versions golangci-lint >/dev/null; then
brew upgrade golangci-lint
else
brew install golangci-lint
fi
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
fi
echo "Setup complete."