forked from 6un9-h0-Dan/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup-husky.sh
executable file
·55 lines (46 loc) · 1.25 KB
/
cleanup-husky.sh
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
#!/usr/bin/env bash
set -e
# Husky modified your git config to store git hooks in the repo, so do that change
currentHooksPath=$(git config core.hooksPath || true)
if [[ $currentHooksPath == ".husky" ]]; then
if [ -z "$SILENT" ]; then
echo "Unsetting git hooks path because it was previously set to .husky."
echo "If you had custom git hooks in .husky you may want to move them to .git/hooks"
fi
git config --unset core.hooksPath
fi
oldHuskyHookNames=(
"applypatch-msg"
"commit-msg"
"post-applypatch"
"post-checkout"
"post-commit"
"post-merge"
"post-receive"
"post-rewrite"
"post-update"
"pre-applypatch"
"pre-auto-gc"
"pre-merge-commit"
"pre-push"
"pre-rebase"
"pre-receive"
"push-to-checkout"
"sendemail-validate"
"update"
)
#
# Also extra-old husky dumped a bunch of hooks into .git/hooks, so check for them
# and rename them so they don't run
for hookName in "${oldHuskyHookNames[@]}"; do
hookPath=".git/hooks/$hookName"
if [[ -f $hookPath ]]; then
if grep -q husky "$hookPath"; then
newHookPath="$hookPath.old"
if [ -z "$SILENT" ]; then
echo "Renaming old husky hook $hookPath to $newHookPath"
fi
mv "$hookPath" "$newHookPath" --suffix=old --backup=numbered
fi
fi
done