-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit for automatically updating date stamps (#660)
# Add pre-commit for automatically updating date stamps Closes #658. Works for me but worth please check this works for you too.
- Loading branch information
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/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 | ||
LINE=$(grep '@date' ${FILE}) | ||
let SPACES=$(echo "${LINE}" | tr -cd ' \t' | wc -c)-4 | ||
NEWLINE=$(printf "%s%$((SPACES))s%s\n" " @date" " " "$(date '+%d %b %Y')") | ||
sed -i~ "s/${LINE}/${NEWLINE}/" ${FILE} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters