##// END OF EJS Templates
Merged r11698 from trunk (#13541)....
Jean-Philippe Lang -
r11517:1afe67bf74d9
parent child
Show More
@@ -219,17 +219,38 module Redmine
219 end
219 end
220
220
221 # Path to the file where scm stderr output is logged
221 # Path to the file where scm stderr output is logged
222 # Returns nil if the log file is not writable
222 def self.stderr_log_file
223 def self.stderr_log_file
223 @stderr_log_path ||=
224 if @stderr_log_file.nil?
224 Redmine::Configuration['scm_stderr_log_file'].presence ||
225 writable = false
225 Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
226 path = Redmine::Configuration['scm_stderr_log_file'].presence
227 path ||= Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
228 if File.exists?(path)
229 if File.file?(path) && File.writable?(path)
230 writable = true
231 else
232 logger.warn("SCM log file (#{path}) is not writable")
233 end
234 else
235 begin
236 File.open(path, "w") {}
237 writable = true
238 rescue => e
239 logger.warn("SCM log file (#{path}) cannot be created: #{e.message}")
240 end
241 end
242 @stderr_log_file = writable ? path : false
243 end
244 @stderr_log_file || nil
226 end
245 end
227
246
228 def self.shellout(cmd, options = {}, &block)
247 def self.shellout(cmd, options = {}, &block)
229 if logger && logger.debug?
248 if logger && logger.debug?
230 logger.debug "Shelling out: #{strip_credential(cmd)}"
249 logger.debug "Shelling out: #{strip_credential(cmd)}"
231 # Capture stderr in a log file
250 # Capture stderr in a log file
232 cmd = "#{cmd} 2>>#{shell_quote(stderr_log_file)}"
251 if stderr_log_file
252 cmd = "#{cmd} 2>>#{shell_quote(stderr_log_file)}"
253 end
233 end
254 end
234 begin
255 begin
235 mode = "r+"
256 mode = "r+"
General Comments 0
You need to be logged in to leave comments. Login now