summaryrefslogtreecommitdiff
path: root/tools/update-copyright.sh
blob: 4df05c030231d33b8d4e0389bd810ffb45ae1aba (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
#!/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-2023 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

tmp_file="w$RANDOM$RANDOM$RANDOM$RANDOM"
[[ -e $tmp_file ]] && tmp_file="w$RANDOM$RANDOM$RANDOM$RANDOM"

# update the dates, creating the interval if it doesn't exist yet
find -iname "*.cpp" -or -iname "*.h" -or -iname "*.hpp" -or -iname "*.inc" -or -iname "*.cc" | 
  xargs sed -i "/Copyright.*The ManaVerse Developers/ s,\(20[0-9]*\) \|\(20[0-9]*\)-20[0-9]* ,\1\2-$new_year ,"

# do a semi-automated commit check
git diff > $tmp_file
echo "The next +/- counts mentioning copyrights should match:"
grep "^[-+][^-+]" $tmp_file | sort | uniq -c
echo "If they don't, try finding the offending files with grep -rl <\$bad_line>"

# Remove temp file
[[ -e $tmp_file ]] && rm $tmp_file