Module: Git::Multi::Nike

Defined in:
lib/git/multi.rb

Overview

the main ‘Git::Multi` capabilities

Instance Method Summary collapse

Instance Method Details

#just_do_it(interactive, pipelined, captured = nil, options = {}) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/git/multi.rb', line 146

def just_do_it(interactive, pipelined, captured = nil, options = {})
  working_dir = case (options[:in] || '').to_sym
                when :parent_dir then parent_dir
                when :local_path then local_path
                else Dir.pwd
                end
  Dir.chdir(working_dir) do
    if $stdout.tty? && $stderr.tty?
      $stdout.puts "#{full_name.invert} (#{fractional_index})"
      interactive.call(self)
    elsif $stderr.tty? && captured
      errors = File.join(Dir.tmpdir, "git-multi.#{$PID}")
      captured.call(self, errors)
      if File.exist?(errors) && !File.zero?(errors)
        # rubocop:disable Style/StderrPuts
        $stderr.puts "#{full_name.invert} (#{fractional_index})"
        Kernel.system "cat #{errors} > /dev/tty ;"
        # rubocop:enable Style/StderrPuts
      end
    else
      pipelined.call(self)
    end
  end
end

#spputs(*args) ⇒ Object

rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity



173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/git/multi.rb', line 173

def spputs(*args)
  # split, prefix and puts
  args.each do |arg|
    case arg
    when Array
      arg.each do |argh| puts("#{full_name}: #{argh}"); end
    when String
      spputs(arg.split($RS))
    else
      ssputs(arg.to_s)
    end
  end
end