Skip to content

Commit d461a42

Browse files
author
Nicolas Rodriguez
committed
Catch Errno::ENOENT exceptions when installing custom hooks
1 parent e3e2f93 commit d461a42

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/redmine_git_hosting/commands/sudo.rb

+3
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ def hash_content(content)
199199
#
200200
def content_from_redmine_side(file)
201201
File.read(file)
202+
rescue Errno::ENOENT => e
203+
logger.error(e.message)
204+
''
202205
end
203206

204207

lib/redmine_git_hosting/gitolite_hook.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ def file_exists?
112112

113113
def install_hook_file
114114
logger.info("Installing hook '#{source_path}' in '#{destination_path}'")
115-
RedmineGitHosting::Commands.sudo_install_file(File.read(source_path), destination_path, filemode)
115+
begin
116+
content = File.read(source_path)
117+
rescue Errno::ENOENT => e
118+
logger.error("Errors while installing hook '#{e.message}'")
119+
return false
120+
else
121+
RedmineGitHosting::Commands.sudo_install_file(content, destination_path, filemode)
122+
end
116123
end
117124

118125

0 commit comments

Comments
 (0)