This repository was archived by the owner on Jun 17, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathundercommit-install
More file actions
Latest commit
executable file
·48 lines (42 loc) · 1.27 KB
/
Copy pathundercommit-install
File metadata and controls
executable file
·48 lines (42 loc) · 1.27 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
#!/usr/bin/env bash
set -euo pipefail
# Configure a place for custom hooks to be installed alongside Overcommit hooks
# (https://github.com/brigade/overcommit). This is useful if you wish to install
# hooks that are specific to your environment, e.g. regenerating editor-specific
# ctags on post-checkout.
#
# After running this script:
#
# - Overcommit hooks are renamed to .git/hooks/{hook}-overcommit.
# - Custom hooks can be installed as .git/hooks/{hook}-custom.
# - Hooks in .git/hooks call Overcommit hooks, then custom hooks, if they exist.
#
# Hooks that aren't managed by Overcommit are ignored.
if [[ !-d .git ]];then
echo"no git repo found in $(pwd)">&2
exit 1
fi
# ruby -r overcommit -e 'puts Overcommit::Utils.supported_hook_types.join("\n")'
OVERCOMMIT_HOOKS="
commit-msg
post-checkout
post-commit
post-merge
post-rewrite
pre-commit
pre-push
pre-rebase
"
HERE=$(cd "$(dirname $0)";pwd -P)
cd .git/hooks
cp "$HERE/master-hook" undercommit-hook
forhookin$OVERCOMMIT_HOOKS;do
if! grep -q OVERCOMMIT $hook;then
echo"$hook doesn't look like an Overcommit hook; aborting"
exit 1
fi
mv "$hook""${hook}-overcommit"
echo"Moved $hook -> ${hook}-overcommit">&2
ln -s undercommit-hook "$hook"
echo"Install custom hook at ${hook}-custom.">&2
done