diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..2629212 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,11 @@ +#!/bin/sh +# Contents of .git/hooks/pre-commit +# Replace `last_modified_at` timestamp with current time +# https://mademistakes.com/notes/adding-last-modified-timestamps-with-git/ + +git diff --cached --name-status | egrep -i "^(A|M).*\.(md)$" | while read a b; do + cat $b | sed "/---.*/,/---.*/s/^lastmod =.*$/lastmod = \'$(date -u "+%Y-%m-%dT%H:%M:%S%z")\'/" > tmp + mv tmp $b + git add $b +done +