Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は jekyll サイトを持っており、特定の投稿の最終コミット日を ruby/grit を使用して検索したいと考えています。
gitを使用して次のことができることを知っています:
git log -1 --format="%cd" -- <file>
ルビー/グリットを使用して同等のことを行うにはどうすればよいですか?
これを簡単に行うことができます:
repo = Grit::Repo.new(...) repo.log('master', path_of_the_file, max_count: 1)[0].date
それが役立つことを願っています!
mtimeのファイル ドキュメントから:
指定されたファイルの変更時刻を Time オブジェクトとして返します。
File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
Ruby はctime、ファイルのディレクトリ情報が変更された場合の にも対応しています。Linux や Mac OS とは異なり、 Windowsctimeはファイルの作成時間をサポートしているため、Windows では動作が少し異なります。
ctime