@@ -69,6 +69,18 @@ def log_commits(opts = {})
6969 command_lines ( 'log' , arr_opts , true ) . map { |l | l . split . first }
7070 end
7171
72+ def full_log_commits ( opts = { } )
73+ arr_opts = [ '--pretty=raw' ]
74+ arr_opts << "-#{ opts [ :count ] } " if opts [ :count ]
75+ arr_opts << "--since=\" #{ opts [ :since ] } \" " if opts [ :since ] . is_a? String
76+ arr_opts << "#{ opts [ :between ] [ 0 ] . to_s } ..#{ opts [ :between ] [ 1 ] . to_s } " if ( opts [ :between ] && opts [ :between ] . size == 2 )
77+ arr_opts << opts [ :object ] if opts [ :object ] . is_a? String
78+ arr_opts << '-- ' + opts [ :path_limiter ] if opts [ :path_limiter ] . is_a? String
79+
80+ full_log = command_lines ( 'log' , arr_opts , true )
81+ process_commit_data ( full_log )
82+ end
83+
7284 def revparse ( string )
7385 command ( 'rev-parse' , string )
7486 end
@@ -87,28 +99,52 @@ def object_size(sha)
8799
88100 # returns useful array of raw commit object data
89101 def commit_data ( sha )
102+ sha = sha . to_s
103+ cdata = command_lines ( 'cat-file' , [ 'commit' , sha ] )
104+ process_commit_data ( cdata , sha )
105+ end
106+
107+ def process_commit_data ( data , sha = nil )
90108 in_message = false
91109
92- hsh = { 'message' => '' , 'parent' => [ ] }
93- command_lines ( 'cat-file' , [ 'commit' , sha . to_s ] ) . each do |line |
94- if in_message
110+ if sha
111+ hsh = { 'sha' => sha , 'message' => '' , 'parent' => [ ] }
112+ else
113+ hsh_array = [ ]
114+ end
115+
116+ data . each do |line |
117+ if in_message && line != ''
95118 hsh [ 'message' ] += line + "\n "
96119 end
97-
120+
98121 if ( line != '' ) && !in_message
99122 data = line . split
100123 key = data . shift
101124 value = data . join ( ' ' )
125+ if key == 'commit'
126+ sha = value
127+ hsh_array << hsh if hsh
128+ hsh = { 'sha' => sha , 'message' => '' , 'parent' => [ ] }
129+ end
102130 if key == 'parent'
103131 hsh [ key ] << value
104132 else
105133 hsh [ key ] = value
106134 end
135+ elsif in_message && line == ''
136+ in_message = false
107137 else
108138 in_message = true
109139 end
110140 end
111- hsh
141+
142+ if hsh_array
143+ hsh_array << hsh if hsh
144+ hsh_array
145+ else
146+ hsh
147+ end
112148 end
113149
114150 def object_contents ( sha )
0 commit comments