Closed jwallwork23 closed 2 months ago
It kind of works:
git add
-ed.I don't know if we want to make a fuss about 1. Can this be done with plain BSD sed?
The behaviour in 2 can be considered a feature. What I added is committed, nothing more. But the hook kindly suggests how I should modify my files so I can review them and then add them. I guess this is normal behaviour, but it was unexpected to me, not having used pre-commit hooks before.
Can you check if using /bin/bash instead of /usr/bin/bash works on linux? Other than that, it's good.
Ah yes, I always forget about this. Works fine on Linux yeah. Thanks!
@einola did the spaces come out okay for you? I had to add a few extra spaces to get things to align nicely. I'm currently using
#!/bin/bash
# An example pre-commit file for nextSIM-DG development
for FILE in $(git diff --cached --name-only | grep -iE '\.(cpp|cc|h|hpp)$'); do
# Apply clang-format for linting
clang-format -i ${FILE} --verbose
# Update date stamp to today's date
sed -i "s/$(grep '\* @date' ${FILE})/ @date $(date '+%d %b %Y')/" ${FILE}
done
I didn't check the alignment :) ... but feel free to change it before merging.
Okay I think the latest commit should preserve spaces. Do the additional commands work on Mac, too?
Add pre-commit for automatically updating date stamps
Closes #658.
Works for me but worth please check this works for you too.