-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·80 lines (66 loc) · 2.31 KB
/
install.sh
File metadata and controls
executable file
·80 lines (66 loc) · 2.31 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# GenCommit Installation Script
set -e
echo "🚀 Installing GenCommit..."
# Check if Go is installed
if ! command -v go &> /dev/null; then
echo "❌ Go is not installed. Please install Go 1.22+ first."
echo " Visit: https://golang.org/dl/"
exit 1
fi
# Check Go version
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
GO_MAJOR=$(echo $GO_VERSION | cut -d. -f1)
GO_MINOR=$(echo $GO_VERSION | cut -d. -f2)
if [ "$GO_MAJOR" -lt 1 ] || ([ "$GO_MAJOR" -eq 1 ] && [ "$GO_MINOR" -lt 22 ]); then
echo "❌ Go version $GO_VERSION is too old. Please install Go 1.22+ first."
exit 1
fi
echo "✅ Go $GO_VERSION detected"
# Check if Ollama is running
if ! curl -s http://localhost:11434/api/tags &> /dev/null; then
echo "⚠️ Warning: Ollama is not running or not accessible at http://localhost:11434"
echo " Please start Ollama with: ollama serve"
echo " And ensure deepseek-r1:8b model is downloaded: ollama pull deepseek-r1:8b"
fi
# Get dependencies
echo "📦 Getting dependencies..."
go mod tidy
go mod download
# Build the binary
echo "🔨 Building GenCommit..."
go build -o gencommit main.go
# Determine installation location
if [ "$EUID" -eq 0 ]; then
# Running as root, install to system
INSTALL_DIR="/usr/local/bin"
echo "📁 Installing to system directory: $INSTALL_DIR"
cp gencommit "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/gencommit"
else
# Running as user, install to local bin
INSTALL_DIR="$HOME/.local/bin"
echo "📁 Installing to user directory: $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
cp gencommit "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/gencommit"
# Check if local bin is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo "⚠️ Warning: $INSTALL_DIR is not in your PATH"
echo " Add this line to your shell profile (~/.zshrc, ~/.bashrc, etc.):"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo " Then restart your terminal or run: source ~/.zshrc"
fi
fi
# Clean up build artifact
rm -f gencommit
echo ""
echo "🎉 GenCommit installed successfully!"
echo ""
echo "Usage:"
echo " cd /path/to/your/git/repo"
echo " gencommit"
echo ""
echo "Make sure Ollama is running with the deepseek-r1:8b model before using."
echo ""
echo "For more information, see README.md"