##// END OF EJS Templates
scm: git: use stdin instead of command line in "git log" (#10470)...
Toshi MARUYAMA -
r9148:3e11f9abfe9d
parent child
Show More
@@ -206,15 +206,15 module Redmine
206 206 self.class.logger
207 207 end
208 208
209 def shellout(cmd, &block)
210 self.class.shellout(cmd, &block)
209 def shellout(cmd, options = {}, &block)
210 self.class.shellout(cmd, options, &block)
211 211 end
212 212
213 213 def self.logger
214 214 Rails.logger
215 215 end
216 216
217 def self.shellout(cmd, &block)
217 def self.shellout(cmd, options = {}, &block)
218 218 if logger && logger.debug?
219 219 logger.debug "Shelling out: #{strip_credential(cmd)}"
220 220 end
@@ -226,7 +226,7 module Redmine
226 226 mode = "r+"
227 227 IO.popen(cmd, mode) do |io|
228 228 io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
229 io.close_write
229 io.close_write unless options[:write_stdin]
230 230 block.call(io) if block_given?
231 231 end
232 232 ## If scm command does not exist,
@@ -197,24 +197,28 module Redmine
197 197
198 198 def revisions(path, identifier_from, identifier_to, options={})
199 199 revs = Revisions.new
200 cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents|
200 cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents --stdin|
201 201 cmd_args << "--reverse" if options[:reverse]
202 202 cmd_args << "-n" << "#{options[:limit].to_i}" if options[:limit]
203 from_to = ""
203 cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
204 revisions = []
204 205 if identifier_from || identifier_to
205 from_to << "#{identifier_from}.." if identifier_from
206 from_to << "#{identifier_to}" if identifier_to
207 cmd_args << from_to if !from_to.empty?
206 revisions << ""
207 revisions[0] << "#{identifier_from}.." if identifier_from
208 revisions[0] << "#{identifier_to}" if identifier_to
208 209 else
209 cmd_args += options[:includes] unless options[:includes].blank?
210 unless options[:includes].blank?
211 revisions += options[:includes]
212 end
210 213 unless options[:excludes].blank?
211 cmd_args << "--not"
212 cmd_args += options[:excludes]
214 revisions += options[:excludes].map{|r| "^#{r}"}
213 215 end
214 216 end
215 cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
216 217
217 git_cmd(cmd_args) do |io|
218 git_cmd(cmd_args, {:write_stdin => true}) do |io|
219 io.binmode
220 io.puts(revisions.join("\n"))
221 io.close_write
218 222 files=[]
219 223 changeset = {}
220 224 parsing_descr = 0 #0: not parsing desc or files, 1: parsing desc, 2: parsing files
@@ -383,7 +387,7 module Redmine
383 387 end
384 388 end
385 389
386 def git_cmd(args, &block)
390 def git_cmd(args, options = {}, &block)
387 391 repo_path = root_url || url
388 392 full_args = ['--git-dir', repo_path]
389 393 if self.class.client_version_above?([1, 7, 2])
@@ -393,6 +397,7 module Redmine
393 397 full_args += args
394 398 ret = shellout(
395 399 self.class.sq_bin + ' ' + full_args.map { |e| shell_quote e.to_s }.join(' '),
400 options,
396 401 &block
397 402 )
398 403 if $? && $?.exitstatus != 0
General Comments 0
You need to be logged in to leave comments. Login now