Project

General

Profile

Feature #306 » 0001-moves-shellout-method-to-Utils-Shell.patch

Jens Krämer, 2017-06-21 11:13

View differences:

lib/redmine/scm/adapters/abstract_adapter.rb
238 238
            end
239 239
          end
240 240
          begin
241
            mode = "r+"
242
            IO.popen(cmd, mode) do |io|
243
              io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
244
              io.close_write unless options[:write_stdin]
245
              block.call(io) if block_given?
246
            end
241
            Redmine::Utils::Shell.shellout(cmd, options, &block)
247 242
          ## If scm command does not exist,
248 243
          ## Linux JRuby 1.6.2 (ruby-1.8.7-p330) raises java.io.IOException
249 244
          ## in production environment.
lib/redmine/utils.rb
82 82
          shell_quote(command)
83 83
        end
84 84
      end
85

  
86
      # Executes the given command through IO.popen and yields an IO object
87
      # representing STDIN / STDOUT
88
      #
89
      # Due to how popen works the command will be executed directly without
90
      # involving the shell if cmd is an array.
91
      def shellout(cmd, options = {}, &block)
92
        mode = "r+"
93
        IO.popen(cmd, mode) do |io|
94
          io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
95
          io.close_write unless options[:write_stdin]
96
          block.call(io) if block_given?
97
        end
98
      end
85 99
    end
86 100

  
87 101
    module DateCalculation
(1-1/11)