summaryrefslogtreecommitdiff
path: root/tools/update-copyright.sh
blob: 3eb813b6fc7139c341113d1eb33ee487985f1717 (plain) (blame)
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
#!/usr/bin/env bash
# Copyright (C) 2001-2010 Wormux Team.
# Copyright (C) 2010 The ManaWorld Development Team.
# Copyright (C) 2012-2016 The ManaPlus Developers.
# Copyright (C) 2021-2025 The ManaVerse Developers.

cd ..
if [[ $1 != "" ]]; then
  new_year="$1"
else
  new_year=$(date +'%Y')
fi

[[ ! -e src ]] && echo "This script should be ran from the top manaverse dirs ./tools/ path." && exit 2

# update the dates, creating the interval if it doesn't exist yet
# N.B: without the type f check, sed replaces symlinks with regular files
find -type f -a \
     \(     -iname "*.cpp" \
        -or -iname "*.cc" \
        -or -iname "*.h" \
        -or -iname "*.hpp" \
        -or -iname "*.in" \
        -or -iname "*.inc" \
        -or -iname "*.sh" \
        -or -iname "*.txt" \
     \) -execdir sed -i "/Copyright.*The ManaVerse Developers/ s,\(20[0-9]*\) \|\(20[0-9]*\)-20[0-9]* ,\1\2-$new_year ," {} \+

printf "The next +/- counts mentioning copyright lines should match:\n"
printf "If they do not, then try finding the offending files with grep -rl <\$bad_line>\n"
# do a semi-automated commit check
git diff | grep "^[-+][^-+]" | sort | uniq -c