Commit 872c66e9 authored by Elan Ruusamäe's avatar Elan Ruusamäe Committed by Sean McGivern

avoid Dir.exists? duplication by moving the check to match_hook_files

parent d87c4b9c
......@@ -72,15 +72,11 @@ class GitlabCustomHook
# <repository>.git/custom_hooks/<hook_name>.d/*
hook_path = File.join(@repo_path, 'custom_hooks', "#{hook_name}.d")
if Dir.exist?(hook_path)
hook_files += match_hook_files(hook_path)
end
hook_files += match_hook_files(hook_path)
# <repository>.git/hooks/<hook_name>.d/*
hook_path = File.join(@repo_path, 'hooks', "#{hook_name}.d")
if Dir.exist?(hook_path)
hook_files += match_hook_files(hook_path)
end
hook_files += match_hook_files(hook_path)
hook_files
end
......@@ -91,6 +87,8 @@ class GitlabCustomHook
#
# the resulting list is sorted
def match_hook_files(path)
return [] unless Dir.exist?(path)
Dir["#{path}/*"].select do |f|
!f.end_with?('~') && File.executable?(f)
end.sort
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment