@@ -96,8 +96,6 @@ def full_log_commits(opts={})
96
96
97
97
process_commit_log_data ( full_log )
98
98
end
99
-
100
-
101
99
102
100
def revparse ( string )
103
101
return string if string =~ /[A-Fa-f0-9]{40}/ # passing in a sha - just no-op it
@@ -153,44 +151,43 @@ def process_commit_data(data, sha = nil, indent = 4)
153
151
return hsh
154
152
end
155
153
156
- def process_commit_log_data ( data , sha = nil , indent = 4 )
154
+ def process_commit_log_data ( data )
157
155
in_message = false
158
156
159
- if sha
160
- hsh = { 'sha' => sha , 'message' => '' , 'parent' => [ ] }
161
- else
162
- hsh_array = [ ]
163
- end
157
+ hsh_array = [ ]
158
+
159
+ hsh = nil
164
160
165
161
data . each do |line |
166
162
line = line . chomp
167
- if line == ''
168
- in_message = !in_message
169
- elsif in_message
170
- hsh [ 'message' ] << line [ indent ..-1 ] << "\n "
171
- else
172
- data = line . split
173
- key = data . shift
174
- value = data . join ( ' ' )
175
- if key == 'commit'
176
- sha = value
163
+
164
+ if line [ 0 ] . nil?
165
+ in_message = !in_message
166
+ next
167
+ end
168
+
169
+ if in_message
170
+ hsh [ 'message' ] << "#{ line [ 4 ..-1 ] } \n "
171
+ next
172
+ end
173
+
174
+ key , *value = line . split
175
+ value = value . join ( ' ' )
176
+
177
+ case key
178
+ when 'commit'
177
179
hsh_array << hsh if hsh
178
- hsh = { 'sha' => sha , 'message' => '' , 'parent' => [ ] }
179
- end
180
- if key == 'parent'
181
- hsh [ key ] << value
180
+ hsh = { 'sha' => value , 'message' => '' , 'parent' => [ ] }
181
+ when 'parent'
182
+ hsh [ 'parent' ] << value
182
183
else
183
184
hsh [ key ] = value
184
- end
185
185
end
186
186
end
187
187
188
- if hsh_array
189
- hsh_array << hsh if hsh
190
- hsh_array
191
- else
192
- hsh
193
- end
188
+ hsh_array << hsh if hsh
189
+
190
+ return hsh_array
194
191
end
195
192
196
193
def object_contents ( sha , &block )
@@ -748,6 +745,7 @@ def command(cmd, opts = [], chdir = true, redirect = '', &block)
748
745
if chdir && ( Dir . getwd != path )
749
746
Dir . chdir ( path ) { out = run_command ( git_cmd , &block ) }
750
747
else
748
+
751
749
out = run_command ( git_cmd , &block )
752
750
end
753
751
0 commit comments