I’ve installed Arch Linux onto a USB drive, essentially creating a portable Linux installation. However, once I cloned the repo of this blog, I found out that the modification times of the files (obviously) changed. Since these were used as the post modifications dates, they were messed up. Thus, I needed to find a different way of tracking the modification dates on the posts.

The module jekyll-last-modified-at seemed to be promising, but unfortunately it havn’t been updated in a while, and conflicts with another plugin that I use on Cygwin.

Eventually I came across this StackOverflow post, which seemed to be a great idea. After a bit of fiddling, it worked like a charm.

For the full changes that I did, see the related commits this and this.

One thing worth noting is that the mv in the script seemed to mess up the permissions of the deploy script, and I figured the easiest way to get out of it is to use sed -i instead, which edits the files in-place. One thing to keep in mind, however, is that this isn’t a POSIX standard, making it less portable.

The source of the pre-commit hook is posted below, since git didn’t seem to track it:

#!/bin/sh

echo Running moddate...
git diff --cached --name-status | while read a b; do
  sed -i "/---.*/,/---.*/s/^moddate:.*$/moddate: $(date "+%Y-%m-%d %T %z")/" $b
  git add $b
done