A git pre-commit hook to do SVN style $Date$ substitution
Put the following in .git/pre-commit (make sure it’s executable):
1 | git diff --cached --name-only > commits_list |
And the following in .git/post-commit:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/bin/bash if [ -f commits_list ] then currentdate=` date ` cat commits_list | while read F do echo $PWD/$F filebase=` basename $F` sed -i -e 's/\$Date[^$]*\$/\$Date ' "$currentdate" '\$/' $PWD/$F sed -i -e 's/\$Filename[^$]*\$/\$Filename ' "$filebase" '\$/' $PWD/$F git add $PWD/$F done rm commits_list git commit --amend --no-verify -C HEAD fi |
Still not extensively tested…