Question

So I can grab the commits from a repo using:

commits = Octokit.commits('tansaku/gitimmersion')

but I can't work out how to get the date of a commit. If I pp an individual commit I can see dates are present:

#<Sawyer::Resource:0x007fb045935358 @_agent=<Sawyer::Agent https://api.github.com/>, @_fields=#<Set: {:author, :committer, :message, :tree, :comment_count}>, @_metaclass=#<Class:#<Sawyer::Resource:0x007fb045935358>>, @_rels=#<Sawyer::Relation::Map: [:self]>, @attrs= {:author=> #<Sawyer::Resource:0x007fb045932590 @_agent=<Sawyer::Agent https://api.github.com/>, @_fields=#<Set: {:name, :email, :date}>, @_metaclass=#<Class:#<Sawyer::Resource:0x007fb045932590>>, @_rels=#<Sawyer::Relation::Map: []>, @attrs= {:name=>"Sam Joseph", :email=>"tansaku@gmail.com", :date=>2014-03-10 14:35:53 UTC}>, :committer=> #<Sawyer::Resource:0x007fb0459302b8 @_agent=<Sawyer::Agent https://api.github.com/>, @_fields=#<Set: {:name, :email, :date}>, @_metaclass=#<Class:#<Sawyer::Resource:0x007fb0459302b8>>, @_rels=#<Sawyer::Relation::Map: []>, @attrs= {:name=>"Sam Joseph", :email=>"tansaku@gmail.com", :date=>2014-03-10 14:35:53 UTC}>, :message=>"using command lines", :tree=> #<Sawyer::Resource:0x007fb045927aa0 @_agent=<Sawyer::Agent https://api.github.com/>, @_fields=#<Set: {:sha}>, @_metaclass=#<Class:#<Sawyer::Resource:0x007fb045927aa0>>, @_rels=#<Sawyer::Relation::Map: [:self]>, @attrs={:sha=>"11b345c2fc315b5f7ae6db2e0f6b0570780c20d1"}>, :comment_count=>0}>

but I can't seem to extract them from these Sawyer objects.

1.9.3-p392 :043 > pp commits[0].author.date nil => nil

1.9.3-p392 :047 > pp commits[0].committer.date nil => nil

Now clearly I'm just being really stupid, but can someone explain how I can get these dates out of the Sawyer objects?

Many thanks in advance CHEERS> SAM

Was it helpful?

Solution

Could this be the solution to your dilemma?

commits[0].commit.author[:date]
=> 2014-03-10 14:35:53 UTC
commits[0].commit.committer[:date]
=> 2014-03-10 14:35:53 UTC

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top