adds githook for lastmod line

This commit is contained in:
Dominic Reich 2023-04-10 09:50:54 +02:00
parent fa1b2556a9
commit 62ed146b53
Signed by: dominic
GPG key ID: BC9D6AE1A3BE169A

11
.githooks/pre-commit Executable file
View file

@ -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