-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_copyright.sh
executable file
·35 lines (28 loc) · 1.15 KB
/
update_copyright.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# Check if a .git file or folder exists (we allow submodules, thus check file and folder), as well as a root cmake file
if [[ ! -e ".git" || ! -f "CMakeLists.txt" ]]; then
echo "ERROR: Must be run from the root folder of your project (where your main CMakeLists.txt file is)"
exit 1
fi
# Get absolute folder for this script
selfFolderPath="`cd "${BASH_SOURCE[0]%/*}"; pwd -P`/" # Command to get the absolute path
# Include utils functions
. "${selfFolderPath}utils.sh"
# Sanity checks
envSanityChecks "sed"
function updateCopyrightYear()
{
local filePattern="$1"
local newYear="$2"
echo "Updating Copyright for all $filePattern files"
find . -iname "$filePattern" -not -path "./3rdparty/*" -not -path "./externals/*" -not -path "./_*" -exec sed -i {} -r -e "s/Copyright \([cC]\) ([0-9]+)-([0-9]+),/Copyright \(C\) \1-$newYear,/" \;
}
year="$(date "+%Y")"
updateCopyrightYear "*.[chi]pp" "$year"
updateCopyrightYear "*.[ch]" "$year"
updateCopyrightYear "*.mm" "$year"
updateCopyrightYear "*.in" "$year"
updateCopyrightYear "*.md" "$year"
updateCopyrightYear "*.txt" "$year"
updateCopyrightYear "*.sh" "$year"
updateCopyrightYear "LICENSE" "$year"