Last active
April 7, 2023 10:08
-
-
Save raphael-brand/1b03a851227eeb0b8773d0054a0f5559 to your computer and use it in GitHub Desktop.
Git Hook - "pre commit" - Add Copyright To Modified File
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
#!/bin/sh | |
CPRGHT_NOTICE='/* Copyright (c) 2023 Raphael Brand | |
License MIT | |
*/ | |
' | |
for file in $(git status --porcelain | grep -E '^(M|A)' | awk '{print $2}') | |
do | |
if ! (( $(grep -ir 'Copyright' $file | wc -l) >= 1 )); then | |
echo "$CPRGHT_NOTICE$(cat $file)" > temp && mv temp $file | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment