]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a script that updates the copyright year of all files.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 13 Jan 2015 20:46:05 +0000 (14:46 -0600)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 15 Jan 2015 02:36:03 +0000 (20:36 -0600)
contrib/utilities/update-copyright [new file with mode: 0755]

diff --git a/contrib/utilities/update-copyright b/contrib/utilities/update-copyright
new file mode 100755 (executable)
index 0000000..2a9b629
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2015 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+
+# Purpose: Update the copyright year of every file based on the last
+#          modification recorded in the git logs
+
+
+if test ! -d source -o ! -d include -o ! -d examples ; then
+  echo "*** This script must be run from the top-level directory of deal.II."
+  exit
+fi
+
+
+files="`echo include/deal.II/*/*h \
+             source/*/*cc \
+             source/*/*in \
+             examples/*/*.cc`
+       `find cmake/ | egrep '\.(cmake|in|cc)$'`
+       `find . -name CMakeLists.txt`
+       `find tests/ | egrep '\.(h|cc)$'`
+       "
+
+for i in $files ; do
+  # get the last year this file was modified from the git log
+  last_year=`git log -n 1 --date=short --format="format:%cd" $i | perl -pi -e 's/.*(\d\d\d\d)-.*/\1/g;'`
+
+  # get the first year this file was modified from the actual
+  # file. this may predate the git log if the file was copied
+  # from elsewhere
+  first_year=`cat $i | egrep 'Copyright \(C\) [0-9]{4}' | \
+              perl -pi -e "s/.*Copyright \(C\) (\d{4}).*/\1/g;"`
+
+  # print a status message. we really only have to update
+  # the copyright year if the first and last year are
+  # different
+  echo "Processing $i: ${first_year} - ${last_year}"
+  if test ! "${first_year}" = "${last_year}" ; then
+    perl -pi -e "s/(Copyright \(C\) \d{4})( - \d{4})?(, \d{4}( - \d{4})?)*/\1 - ${last_year}/g;" $i
+  fi
+done

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.