File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,20 @@ if test -z "${1-}"; then
8484fi
8585# #################################################################################################################################################
8686
87+ function find_first_existing_file() {
88+ local file
89+
90+ for file in " $@ " ; do
91+ if test -e " $file " ; then
92+ echo " $file "
93+ return 0
94+ fi
95+ done
96+
97+ log_stderr " no existing files found for: $* "
98+ return 1
99+ }
100+
87101function install_base_hook_script() {
88102 local hook_type install_to_file
89103 hook_type=" $1 "
@@ -126,8 +140,12 @@ function install_base_hook_script() {
126140
127141function install_hook() {
128142 local hook_name hook_file hook_type install_to_dir install_to_file
129- hook_name=" $1 "
130- hook_file=" ${HOOKS_DIR} /${hook_name} "
143+
144+ if ! hook_file=" $( find_first_existing_file " $1 " " ${HOOKS_DIR} /$1 " ) " ; then
145+ exit_fatal_with_usage " could not find hook file for: $1 "
146+ fi
147+
148+ hook_name=" $( basename " $hook_file " ) "
131149 hook_type=" ${hook_name% _* } "
132150 install_base_hook_script " $hook_type "
133151 install_to_dir=" ${INSTALL_TO_HOOKS_DIR} /${hook_type} .d"
You can’t perform that action at this time.
0 commit comments