-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-dev.sh
More file actions
executable file
·65 lines (56 loc) · 2.84 KB
/
Copy pathsetup-dev.sh
File metadata and controls
executable file
·65 lines (56 loc) · 2.84 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
#!/usr/bin/env bash
# setup-dev.sh — one-time developer environment setup.
#
# Run once after cloning:
# chmod +x setup-dev.sh && ./setup-dev.sh
#
# What it does:
# 1. Configures git to use .githooks/ (activates pre-commit / pre-push).
# 2. Detects a mismatched global git identity and sets a repo-local one.
# 3. Registers the global email as blocked in .git/config so the hooks
# catch it — no email is hardcoded in the repo itself.
# 4. Creates a Python venv and installs test dependencies.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$REPO_ROOT"
echo "=== Print Bridge dev setup ==="
# ── 1. Activate hooks ─────────────────────────────────────────────────────────
echo "→ Setting core.hooksPath = .githooks"
git config core.hooksPath .githooks
chmod +x .githooks/pre-commit .githooks/pre-push
echo " Hooks installed."
# ── 2. Identity check ─────────────────────────────────────────────────────────
CANONICAL_EMAIL="rubeecube@users.noreply.github.com"
CANONICAL_NAME="rubeecube"
GLOBAL_EMAIL=$(git config --global user.email 2>/dev/null || echo "")
REPO_EMAIL=$(git config user.email 2>/dev/null || echo "")
if [[ "$GLOBAL_EMAIL" != "$CANONICAL_EMAIL" && "$REPO_EMAIL" != "$CANONICAL_EMAIL" ]]; then
echo ""
echo " ⚠ Global git email differs from the canonical repo identity."
echo " Setting repo-local identity to: $CANONICAL_EMAIL"
git config user.name "$CANONICAL_NAME"
git config user.email "$CANONICAL_EMAIL"
# Register the detected global email as blocked so the hooks catch it.
# This lives only in .git/config — never committed or pushed.
if [[ -n "$GLOBAL_EMAIL" ]]; then
EXISTING=$(git config hooks.blocked-author-emails 2>/dev/null || echo "")
if [[ -z "$EXISTING" ]]; then
git config hooks.blocked-author-emails "$GLOBAL_EMAIL"
elif [[ "$EXISTING" != *"$GLOBAL_EMAIL"* ]]; then
git config hooks.blocked-author-emails "$EXISTING,$GLOBAL_EMAIL"
fi
echo " Global email registered in hooks.blocked-author-emails (.git/config)."
fi
echo ""
fi
echo " Git identity: $(git config user.name) <$(git config user.email)>"
# ── 3. Python venv ────────────────────────────────────────────────────────────
if [[ ! -d venv ]]; then
echo "→ Creating Python venv"
python3 -m venv venv
fi
echo "→ Installing test dependencies"
venv/bin/pip install --quiet -r requirements-test.txt
echo ""
echo "=== Setup complete. Run tests with: ==="
echo " ./venv/bin/pytest tests/ -v"