如何使用 ruby/grit 获取文件的最后提交日期?
我有一个 jekyll 网站,我想使用 ruby/grit 查找某个帖子的最后提交日期。
我知道我可以使用 git 执行以下操作:
git log -1 --format="%cd" -- <file>
请问如何使用 ruby/grit 执行等效操作?
I have a jekyll site, and I want to find the last commit date of a certain post using ruby/grit.
I know that I can do the following using git:
git log -1 --format="%cd" -- <file>
How can I do something equivalent using ruby/grit please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以简单地这样做:
希望有帮助!
You can simply do this:
Hope that helps!
来自 mtime 的文件文档:
Ruby 还支持
ctime
,这是文件的目录信息被更改的时间。在 Windows 上,ctime
的行为略有不同,因为 Windows 支持文件的创建时间,这与 Linux 和 Mac OS 不同。From the File documentation for mtime:
Ruby also supports
ctime
, which is when the directory information for the file was changed. On Windowsctime
is a little different behavior, because Windows supports creation times for files, unlike Linux and Mac OS.