Skip to content

Commit 37ff374

Browse files
committed
[git_commit_and_push_all] various updates
1 parent d7375f5 commit 37ff374

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

dotfiles/bin/install_git_hook

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ if test -z "${1-}"; then
8484
fi
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+
87101
function 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

127141
function 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"

0 commit comments

Comments
 (0)