This repository was archived by the owner on Mar 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-setup.sh
More file actions
executable file
·105 lines (90 loc) · 2.72 KB
/
git-setup.sh
File metadata and controls
executable file
·105 lines (90 loc) · 2.72 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
# =============================================================================
# Git Setup Helper - Installs pre-commit hooks and configures git for the project
# =============================================================================
set -euo pipefail
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
log_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
log_success() { echo -e "${GREEN}✅ $1${NC}"; }
log_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
echo "🔧 Git Setup for Chatimics Project"
echo "=================================="
# Install pre-commit hook
log_info "Installing pre-commit hook..."
if [[ -f .githooks/pre-commit ]]; then
# Create .git/hooks directory if it doesn't exist
mkdir -p .git/hooks
# Copy the pre-commit hook
cp .githooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
log_success "Pre-commit hook installed"
else
log_warning "Pre-commit hook not found at .githooks/pre-commit"
fi
# Configure git to ignore certain files globally for this repo
log_info "Configuring git settings for this repository..."
# Set up git attributes for better diff handling
cat > .gitattributes << 'EOF'
# Text files
*.md text
*.txt text
*.yml text
*.yaml text
*.json text
*.js text
*.ts text
*.tsx text
*.css text
*.sh text
# Binary files
*.db binary
*.key binary
*.pem binary
*.p12 binary
*.pfx binary
# Docker files
Dockerfile text
docker-compose.yml text
# Ensure shell scripts have LF line endings
*.sh text eol=lf
EOF
log_success "Git attributes configured"
# Check current git status
log_info "Checking git status..."
if git status --porcelain | grep -q .; then
log_warning "You have uncommitted changes:"
git status --short
echo ""
echo "Consider committing these changes:"
echo " git add ."
echo " git commit -m 'Optimize .gitignore and improve project rebuilding'"
else
log_success "Working directory is clean"
fi
# Suggest some useful git aliases for this project
log_info "Suggested git aliases (run these if you want):"
echo ""
echo "# Quick status check"
echo "git config alias.st 'status --short'"
echo ""
echo "# Better log formatting"
echo "git config alias.lg 'log --oneline --graph --decorate'"
echo ""
echo "# Check what would be committed"
echo "git config alias.staged 'diff --cached'"
echo ""
echo "# Validate project before commit"
echo "git config alias.validate '!./validate-project.sh'"
echo ""
log_success "Git setup complete!"
echo ""
echo "🛡️ Security features enabled:"
echo " ✅ Pre-commit hook prevents sensitive data commits"
echo " ✅ .gitignore optimized for Matrix homeserver project"
echo " ✅ Binary file handling configured"
echo ""
echo "🚀 Ready to commit safely!"