forked from steveyegge/beads
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (75 loc) · 2.38 KB
/
install.sh
File metadata and controls
executable file
·83 lines (75 loc) · 2.38 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
#!/usr/bin/env bash
#
# Install Beads git hooks
#
# This script copies the hooks to .git/hooks/ and makes them executable
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
# Check if we're in a git repository
if ! git rev-parse --git-dir &> /dev/null; then
echo "Error: Not in a git repository"
exit 1
fi
echo "Installing Beads git hooks to $HOOKS_DIR"
echo ""
# Install pre-commit hook
if [[ -f "$HOOKS_DIR/pre-commit" ]]; then
echo "⚠ $HOOKS_DIR/pre-commit already exists"
read -p "Overwrite? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping pre-commit"
else
cp "$SCRIPT_DIR/pre-commit" "$HOOKS_DIR/pre-commit"
chmod +x "$HOOKS_DIR/pre-commit"
echo "✓ Installed pre-commit hook"
fi
else
cp "$SCRIPT_DIR/pre-commit" "$HOOKS_DIR/pre-commit"
chmod +x "$HOOKS_DIR/pre-commit"
echo "✓ Installed pre-commit hook"
fi
# Install post-merge hook
if [[ -f "$HOOKS_DIR/post-merge" ]]; then
echo "⚠ $HOOKS_DIR/post-merge already exists"
read -p "Overwrite? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping post-merge"
else
cp "$SCRIPT_DIR/post-merge" "$HOOKS_DIR/post-merge"
chmod +x "$HOOKS_DIR/post-merge"
echo "✓ Installed post-merge hook"
fi
else
cp "$SCRIPT_DIR/post-merge" "$HOOKS_DIR/post-merge"
chmod +x "$HOOKS_DIR/post-merge"
echo "✓ Installed post-merge hook"
fi
# Install post-checkout hook
if [[ -f "$HOOKS_DIR/post-checkout" ]]; then
echo "⚠ $HOOKS_DIR/post-checkout already exists"
read -p "Overwrite? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping post-checkout"
else
cp "$SCRIPT_DIR/post-checkout" "$HOOKS_DIR/post-checkout"
chmod +x "$HOOKS_DIR/post-checkout"
echo "✓ Installed post-checkout hook"
fi
else
cp "$SCRIPT_DIR/post-checkout" "$HOOKS_DIR/post-checkout"
chmod +x "$HOOKS_DIR/post-checkout"
echo "✓ Installed post-checkout hook"
fi
echo ""
echo "✓ Beads git hooks installed successfully!"
echo ""
echo "These hooks will:"
echo " • Export issues to JSONL before every commit"
echo " • Import issues from JSONL after merges"
echo " • Import issues from JSONL after branch checkouts"
echo ""
echo "To uninstall, simply delete the hooks from $HOOKS_DIR"