-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·95 lines (87 loc) · 2.93 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·95 lines (87 loc) · 2.93 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
#!/usr/bin/env bash
#
# Installer for ai-commit-hook
# Installs the commit-msg hook globally or into the current repo.
#
set -euo pipefail
HOOK_SOURCE="$(cd "$(dirname "$0")" && pwd)/commit-msg"
BOLD='\033[1m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
RESET='\033[0m'
echo -e "${CYAN}"
echo ' _ ___ ____ _ _ '
echo ' / \ |_ _| / ___|___ _ __ ___ _ __ ___ (_) |_ '
echo ' / _ \ | | | | / _ \| '\''_ ` _ \| '\''_ ` _ \| | __|'
echo ' / ___ \ | | | |__| (_) | | | | | | | | | | | | |_ '
echo '/_/ \_\___| \____\___/|_| |_| |_|_| |_| |_|_|\__|'
echo -e "${RESET}"
echo -e "${BOLD}Because your manager needs to see AI in every commit.${RESET}"
echo ""
usage() {
echo "Usage: $0 [--global | --local | --uninstall-global | --uninstall-local]"
echo ""
echo " --global Install hook for all future repos (git >= 2.9)"
echo " --local Install hook in the current repository"
echo " --uninstall-global Remove the global hook"
echo " --uninstall-local Remove the hook from the current repository"
echo ""
exit 1
}
install_global() {
local hook_dir="${HOME}/.git-hooks"
mkdir -p "$hook_dir"
cp "$HOOK_SOURCE" "$hook_dir/commit-msg"
chmod +x "$hook_dir/commit-msg"
git config --global core.hooksPath "$hook_dir"
echo -e "${GREEN}✓ Global hook installed!${RESET}"
echo -e " Hook location: ${BOLD}${hook_dir}/commit-msg${RESET}"
echo -e " All your repos will now show Claude as a co-author."
echo -e " ${YELLOW}Your KPIs will be through the roof.${RESET}"
}
install_local() {
if [ ! -d ".git" ]; then
echo "Error: Not inside a git repository. Run this from your repo root." >&2
exit 1
fi
local hook_dir=".git/hooks"
cp "$HOOK_SOURCE" "$hook_dir/commit-msg"
chmod +x "$hook_dir/commit-msg"
echo -e "${GREEN}✓ Local hook installed!${RESET}"
echo -e " Hook location: ${BOLD}${hook_dir}/commit-msg${RESET}"
echo -e " This repo's commits will now feature Claude as a co-author."
}
uninstall_global() {
local hook_dir="${HOME}/.git-hooks"
if [ -f "$hook_dir/commit-msg" ]; then
rm "$hook_dir/commit-msg"
echo -e "${GREEN}✓ Global hook removed.${RESET}"
# Only unset hooksPath if the directory is now empty
if [ -z "$(ls -A "$hook_dir" 2>/dev/null)" ]; then
git config --global --unset core.hooksPath 2>/dev/null || true
rmdir "$hook_dir" 2>/dev/null || true
fi
else
echo "No global hook found."
fi
}
uninstall_local() {
if [ ! -d ".git" ]; then
echo "Error: Not inside a git repository." >&2
exit 1
fi
if [ -f ".git/hooks/commit-msg" ]; then
rm ".git/hooks/commit-msg"
echo -e "${GREEN}✓ Local hook removed.${RESET}"
else
echo "No local hook found."
fi
}
case "${1:-}" in
--global) install_global ;;
--local) install_local ;;
--uninstall-global) uninstall_global ;;
--uninstall-local) uninstall_local ;;
*) usage ;;
esac