gpt4 book ai didi

ruby - 如何使用 octokit.rb 获取提交日期

转载 作者:数据小太阳 更新时间:2023-10-29 07:34:04 27 4
gpt4 key购买 nike

所以我可以使用以下方法从 repo 中获取提交:

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

但我不知道如何获取提交日期。如果我 pp 一个单独的提交,我可以看到日期存在:

#<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}>

但我似乎无法从这些 Sawyer 对象中提取它们。

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

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

现在很明显我真的很愚蠢,但是有人可以解释我如何从 Sawyer 对象中获取这些日期吗?

非常感谢干杯>萨姆

最佳答案

这能解决您的难题吗?

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

关于ruby - 如何使用 octokit.rb 获取提交日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22466493/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com