-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-hook-remove.sh
30 lines (24 loc) · 919 Bytes
/
git-hook-remove.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
#!/bin/bash
# "git-hook-remove.sh" by Tristano Ajmone (CC0) v1.0.0 | 2021/04/19
#===============================================================================
# Uninstalls the Git hook created by "git-hook-install.sh".
#-------------------------------------------------------------------------------
# Based on a script created by Alexander Bolli @SicroAtGit.
#===============================================================================
hookScript=pre-commit-validate.sh
cd .git/hooks/ || { echo 'Uninstallation failed!'; exit 1; }
# =====================
# 1. Delete Hook Script
# =====================
if [ -f $hookScript ] ; then
rm $hookScript
fi
if ! [ -f pre-commit ] ; then
exit
fi
# ===================================
# 2. Remove Hook Script from Git Hook
# ===================================
temp=$(mktemp)
grep -Fxv ".git/hooks/$hookScript" pre-commit > $temp
mv $temp pre-commit