Method: Git::Lib#process_commit_log_data

Defined in:
lib/git/lib.rb

#process_commit_log_data(data) ⇒ Object



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/git/lib.rb', line 229

def process_commit_log_data(data)
  in_message = false
        
  hsh_array = []       

  hsh = nil

  data.each do |line|
    line = line.chomp
    
    if line[0].nil?
      in_message = !in_message 
      next
    end
   
    if in_message
      hsh['message'] << "#{line[4..-1]}\n"
      next
    end

    key, *value = line.split
    value = value.join(' ')
    
    case key
      when 'commit'
        hsh_array << hsh if hsh
        hsh = {'sha' => value, 'message' => '', 'parent' => []}
      when 'parent'
        hsh['parent'] << value
      else
        hsh[key] = value
    end
  end
  
  hsh_array << hsh if hsh
    
  return hsh_array
end