Skip to content

Commit ff2c20c

Browse files
author
Nicolas Rodriguez
committed
Check if hook's permissions has changed
1 parent d461a42 commit ff2c20c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/redmine_git_hosting/commands/sudo.rb

+11
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ def sudo_file_changed?(source_file, dest_file)
134134
end
135135

136136

137+
# Test if file permissions has changed
138+
#
139+
def sudo_file_perms_changed?(filemode, dest_file)
140+
current_mode = sudo_capture('stat', '-c', "%a", dest_file)
141+
current_mode.chomp != filemode
142+
rescue RedmineGitHosting::Error::GitoliteCommandException => e
143+
logger.error(e.output)
144+
false
145+
end
146+
147+
137148
# Return only the output of the shell command.
138149
# Throws an exception if the shell command does not exit with code 0.
139150
#

lib/redmine_git_hosting/gitolite_hook.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def logger
101101

102102

103103
def hook_file_has_changed?
104-
RedmineGitHosting::Commands.sudo_file_changed?(source_path, destination_path)
104+
RedmineGitHosting::Commands.sudo_file_changed?(source_path, destination_path) ||
105+
RedmineGitHosting::Commands.sudo_file_perms_changed?(filemode, destination_path)
105106
end
106107

107108

0 commit comments

Comments
 (0)