try to fix the git add problem on the pre-commit git hook

Whenever I want to commit only some hunks of a file, this always
commited the full file when it updated the lastmod frontmatter of
changed files.

making different commits for unrelated changes impossible (but it always
held the lastmod date as accurate as possible)

hope this helps
This commit is contained in:
Dominic Reich 2024-12-27 06:50:01 +01:00
parent d74ab2861f
commit 624ee61121
Signed by: dominic
GPG key ID: 0B5787DB23049C45

View file

@ -9,6 +9,6 @@ git diff --cached --name-status | grep -E -i "^(A|M).*\.(md)$" | while read a b;
(grep -E "^---$" $b > /dev/null) && (cat $b | sed "/---.*/,/---.*/s/^lastmod:.*$/lastmod: $(date -u "+%Y-%m-%dT%H:%M:%S%z")/" > tmp) (grep -E "^---$" $b > /dev/null) && (cat $b | sed "/---.*/,/---.*/s/^lastmod:.*$/lastmod: $(date -u "+%Y-%m-%dT%H:%M:%S%z")/" > tmp)
(grep -E "^\+\+\+$" $b > /dev/null) && (cat $b | sed "/+++.*/,/+++.*/s/^lastmod.*$/lastmod = '$(date -u "+%Y-%m-%dT%H:%M:%S%z")'/" > tmp) (grep -E "^\+\+\+$" $b > /dev/null) && (cat $b | sed "/+++.*/,/+++.*/s/^lastmod.*$/lastmod = '$(date -u "+%Y-%m-%dT%H:%M:%S%z")'/" > tmp)
mv tmp $b mv tmp $b
git add $b git add -p $b
done done