Permalink
Browse files

Tweak to file modification to not break if the file isnt committed yet

  • Loading branch information...
1 parent 6aa4315 commit 7558bfe3420fcadef82a16919a6bf11fde18b64f @krobertson krobertson committed Mar 30, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 _plugins/post_date_file_modified.rb
@@ -8,17 +8,17 @@ def full_path_to_source
module Jekyll
class PostDateFileModified < Generator
-
safe true
priority :high
def generate(site)
require 'grit'
repo = Grit::Repo.new(File.join(__FILE__, '..', '..'))
site.posts.each do |post|
- post.date = repo.log('master', post.full_path_to_source, :max_count => 1).first.authored_date
+ if latest_commit = repo.log('master', post.full_path_to_source, :max_count => 1).first
+ post.date = latest_commit.authored_date
+ end
end
end
-
end
end

0 comments on commit 7558bfe

Please sign in to comment.