Use git to calculate trusted mtimes

You can remark at the bottom of each page I provide a last modification date. This label was first calculated using the mtime of the file on the file system. But many times I modify this date just to force some recompilation. Therefore the date wasn’t a date of real modification.

I use git to version my website. And fortunately I can know the last date of real change of a file. This is how I do this with nanoc:

Of course I know it is really slow and absolutely not optimized. But it works as expected. Now the date you see at the bottom is exactly the date I modified the content of the page.

Edit: Thanks to Eric Sunshine and Kris to provide me some hints at cleaning my code.


comments powered by Disqus
Published on 2010-09-02
Follow @yogsototh
Yann Esposito©
Done with Vim spacemacs & nanoc Hakyll

ADA: DdzFFzCqrhtAvdkmATx5Fm8NPJViDy85ZBw13p4XcNzVzvQg8e3vWLXq23JQWFxPEXK6Kvhaxxe7oJt4VMYHxpA2vtCFiP8fziohN6Yp