Finding true last modified date/time; a better way?

This isn’t a middleman question per say so please and I know this is a bit of strange question, of course you would use File.mtime() for find the last modified time.

However, I’m doing my build and deploy remotely, on Heroku, so mtime will not necessarily be the last time the file is modified but Heroku build time.

So right now my working solution is something like this… but this fails to work on Heroku… so it is a solution… but not one me.

source_obj = `git rev-list -n 1 HEAD #{article.source_file}`.chomp

correct_mod = DateTime.parse(`git show --pretty=format:%ai --abbrev-commit #{source_obj} | head -n 1`.chomp).iso8601

Can anyone think of a better (cleaner, more efficient) way of doing this?

I do essentially that in the middleman-vcs-time extension but have only tested it locally. In what way does it fail on Heroku?

@Andrew

I will have to check out the extension, thanks :wink:

The general solution fails on Heroku because they seem drop the .git file someplace in the deployment process. In some aspects that does make sense as the .git folder would be spun into the build slug.

Is it safe to assume that this wouldn’t work for pages that include content from partials or yaml files?

That is correct, the modification date changes when the document itself is updated and not the supporting documents/bits that help render the page.