public
Fork of mojombo/grit
Description: Grit is a Ruby library for extracting information from a git repository in an object oriented manner.
Homepage: http://grit.rubyforge.org/
Clone URL: git://github.com/dustin/grit.git
Search Repo:
Touch up Commit#to_hash

* Use string instead of symbol keys
* Return parents as 'id' => ID rather than array of id strings
defunkt (author)
Mon Mar 10 18:10:42 -0700 2008
commit  ad44b88d69c4b7b61a9ec12445f00f082ca19f41
tree    3694a0e49cf01cc4b5b87536b969dceb796c78ae
parent  78617eaee2ca3b88cd9bb5361d29a99b5555a3d2
...
187
188
189
190
191
192
193
194
195
196
 
 
 
 
 
 
 
197
198
199
200
 
 
 
201
202
203
 
 
204
205
206
...
187
188
189
 
 
 
 
 
 
 
190
191
192
193
194
195
196
197
 
 
 
198
199
200
201
 
 
202
203
204
205
206
0
@@ -187,20 +187,20 @@ module Grit
0
 
0
     def to_hash
0
       {
0
- :id => id,
0
- :parents => parents.map { |p| p.id },
0
- :tree => tree.id,
0
- :message => message,
0
- :author => {
0
- :name => author.name,
0
- :email => author.email
0
+ 'id' => id,
0
+ 'parents' => parents.map { |p| { 'id' => p.id } },
0
+ 'tree' => tree.id,
0
+ 'message' => message,
0
+ 'author' => {
0
+ 'name' => author.name,
0
+ 'email' => author.email
0
         },
0
- :committer => {
0
- :name => committer.name,
0
- :email => committer.email
0
+ 'committer' => {
0
+ 'name' => committer.name,
0
+ 'email' => committer.email
0
         },
0
- :authored_date => authored_date.xmlschema,
0
- :committed_date => committed_date.xmlschema,
0
+ 'authored_date' => authored_date.xmlschema,
0
+ 'committed_date' => committed_date.xmlschema,
0
       }
0
     end
0
   end # Commit
...
161
162
163
 
 
164
165
166
167
168
169
170
171
172
173
174
175
 
 
 
 
 
 
 
 
176
177
178
...
161
162
163
164
165
166
167
168
169
 
 
 
 
 
 
 
 
170
171
172
173
174
175
176
177
178
179
180
0
@@ -161,18 +161,20 @@ class TestCommit < Test::Unit::TestCase
0
     assert_equal %Q{#<Grit::Commit "abc">}, @c.inspect
0
   end
0
 
0
+ # to_hash
0
+
0
   def test_to_hash
0
     @c = Commit.create(@r, :id => '4c8124ffcf4039d292442eeccabdeca5af5c5017')
0
 
0
     expected = {
0
- :parents => ["634396b2f541a9f2d58b00be1a07f0c358b999b3"],
0
- :committed_date => "2007-10-10T00:06:12-07:00",
0
- :tree => "672eca9b7f9e09c22dcb128c283e8c3c8d7697a4",
0
- :authored_date => "2007-10-10T00:06:12-07:00",
0
- :committer => {:email => "tom@mojombo.com", :name => "Tom Preston-Werner"},
0
- :message => "implement Grit#heads",
0
- :author => {:email => "tom@mojombo.com", :name => "Tom Preston-Werner"},
0
- :id => "4c8124ffcf4039d292442eeccabdeca5af5c5017"
0
+ 'parents' => ['id' => "634396b2f541a9f2d58b00be1a07f0c358b999b3"],
0
+ 'committed_date' => "2007-10-10T00:06:12-07:00",
0
+ 'tree' => "672eca9b7f9e09c22dcb128c283e8c3c8d7697a4",
0
+ 'authored_date' => "2007-10-10T00:06:12-07:00",
0
+ 'committer' => {'email' => "tom@mojombo.com", 'name' => "Tom Preston-Werner"},
0
+ 'message' => "implement Grit#heads",
0
+ 'author' => {'email' => "tom@mojombo.com", 'name' => "Tom Preston-Werner"},
0
+ 'id' => "4c8124ffcf4039d292442eeccabdeca5af5c5017"
0
     }
0
 
0
     assert_equal expected, @c.to_hash

Comments

    No one has commented yet.