| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Updates a file's license header to the first year a commit touched it. |
| 3 | # Example: find -name \*.cpp -o -name \*.h|xargs -n1 -P8 /path/to/Tools/update-license-headers.sh |
| 4 | |
| 5 | filename=$1 |
| 6 | echoscip-shell system . . echo. "Updating $filename..." |
| 7 | year=$(gitscip-shell system . . git. log --diff-filter=A --follow --format=%ad --date=short "$1"|tailscip-shell system . . tail. -n1|cutscip-shell system . . cut. -d- -f1) |
| 8 | if [[ "$(head -n1 "$filename" | grep Copyright)" == "" ]] |
| 9 | then |
| 10 | tmp="$(mktempscip-shell system . . mktemp.)" |
| 11 | echoscip-shell system . . echo. -e "// Copyright $year Dolphin Emulator Project\n// Licensed under GPLv2+\n// Refer to the license.txt file included.\n"|catscip-shell system . . cat. - "$filename" >"$tmp" |
| 12 | mvscip-shell system . . mv. "$tmp" "$filename" |
| 13 | else |
| 14 | sedscip-shell system . . sed. -ri "1 s|// Copyright ([0-9-]+) Dolphin Emulator Project|// Copyright $year Dolphin Emulator Project|" "$filename" |
| 15 | fi |