diff options
author | Fedja Beader <fedja@protonmail.ch> | 2025-06-04 19:47:49 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2025-06-04 19:47:49 +0000 |
commit | fdeda0cf5a848921a34746d39029b99c296f9bf4 (patch) | |
tree | cac119a05129ea0e6e647b87858e23d3e4b44d6f | |
parent | e81e12771ae0256f511567b81da36a1b66017fd9 (diff) | |
download | manaplus-fdeda0cf5a848921a34746d39029b99c296f9bf4.tar.gz manaplus-fdeda0cf5a848921a34746d39029b99c296f9bf4.tar.bz2 manaplus-fdeda0cf5a848921a34746d39029b99c296f9bf4.tar.xz manaplus-fdeda0cf5a848921a34746d39029b99c296f9bf4.zip |
Rewrite copyright-updating tool to make it more readable and not use temporary files
add *.in and *.txt and *.sh (the ones missed by existing version)
TODO: it rewrites "test.txt" in data/test/test2.txt into two lines of "test line 1" and "test line 2". I don't know why.
.. and test copyright update in same MR
Squashed with:
* Resolve test2.txt mistery
****
mana/plus!182
-rwxr-xr-x | tools/update-copyright.sh | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/tools/update-copyright.sh b/tools/update-copyright.sh index 4df05c030..3eb813b6f 100755 --- a/tools/update-copyright.sh +++ b/tools/update-copyright.sh @@ -2,7 +2,7 @@ # 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. +# Copyright (C) 2021-2025 The ManaVerse Developers. cd .. if [[ $1 != "" ]]; then @@ -13,18 +13,20 @@ 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 ," +# 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 > $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 +git diff | grep "^[-+][^-+]" | sort | uniq -c |