update-copyright.sh 1015 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. # Copyright (C) 2001-2010 Wormux Team.
  3. # Copyright (C) 2010 The ManaWorld Development Team.
  4. # Copyright (C) 2012-2016 The ManaPlus Developers.
  5. cd ..
  6. new_year="$1"
  7. [[ -z $new_year ]] && echo "Missing parameter: year" && exit 1
  8. [[ ! -e src ]] && echo "This script should be ran from the top manaplus dir" && exit 2
  9. tmp_file="w$RANDOM$RANDOM$RANDOM$RANDOM"
  10. [[ -e $tmp_file ]] && tmp_file="w$RANDOM$RANDOM$RANDOM$RANDOM"
  11. # update the dates, creating the interval if it doesn't exist yet
  12. find -iname "*.cpp" -or -iname "*.h" -or -iname "*.hpp" -or -iname "*.inc" -or -iname "*.cc" |
  13. xargs sed -i "/Copyright.*The ManaPlus Developers/ s,\(20[0-9]*\) \|\(20[0-9]*\)-20[0-9]* ,\1\2-$new_year ,"
  14. # do a semi-automated commit check
  15. git diff > $tmp_file
  16. echo "The next +/- counts mentioning copyrights should match:"
  17. grep "^[-+][^-+]" $tmp_file | sort | uniq -c
  18. echo "If they don't, try finding the offending files with grep -rl <\$bad_line>"
  19. # Remove temp file
  20. [[ -e $tmp_file ]] && rm $tmp_file