Skip to content

Commit 97e1fff

Browse files
Fixing how multi-line commits are parsed
closes #99 refs #83
1 parent 209d9aa commit 97e1fff

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

lib/git/lib.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def full_log_commits(opts={})
9393
arr_opts += log_path_options(opts)
9494

9595
full_log = command_lines('log', arr_opts, true)
96-
process_commit_data(full_log)
96+
97+
process_commit_log_data(full_log)
9798
end
9899

99100

@@ -129,6 +130,30 @@ def commit_data(sha)
129130
end
130131

131132
def process_commit_data(data, sha = nil, indent = 4)
133+
hsh = {
134+
'sha' => sha,
135+
'message' => '',
136+
'parent' => []
137+
}
138+
139+
loop do
140+
key, *value = data.shift.split
141+
142+
break if key.nil?
143+
144+
if key == 'parent'
145+
hsh['parent'] << value.join(' ')
146+
else
147+
hsh[key] = value.join(' ')
148+
end
149+
end
150+
151+
hsh['message'] = data.collect {|line| line[indent..-1]}.join("\n") + "\n"
152+
153+
return hsh
154+
end
155+
156+
def process_commit_log_data(data, sha = nil, indent = 4)
132157
in_message = false
133158

134159
if sha

0 commit comments

Comments
 (0)