Skip to content

Commit

Permalink
Fixing how multi-line commits are parsed
Browse files Browse the repository at this point in the history
closes #99
refs #83
  • Loading branch information
robertodecurnex committed Jan 17, 2014
1 parent 209d9aa commit 97e1fff
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/git/lib.rb
Expand Up @@ -93,7 +93,8 @@ def full_log_commits(opts={})
arr_opts += log_path_options(opts)

full_log = command_lines('log', arr_opts, true)
process_commit_data(full_log)

process_commit_log_data(full_log)
end


Expand Down Expand Up @@ -129,6 +130,30 @@ def commit_data(sha)
end

def process_commit_data(data, sha = nil, indent = 4)
hsh = {
'sha' => sha,
'message' => '',
'parent' => []
}

loop do
key, *value = data.shift.split

break if key.nil?

if key == 'parent'
hsh['parent'] << value.join(' ')
else
hsh[key] = value.join(' ')
end
end

hsh['message'] = data.collect {|line| line[indent..-1]}.join("\n") + "\n"

return hsh
end

def process_commit_log_data(data, sha = nil, indent = 4)
in_message = false

if sha
Expand Down

0 comments on commit 97e1fff

Please sign in to comment.