Skip to contentSkip to conversation

dev-tools: Added script for updating copyright years in files

PATCH In review David Sommerseth 2 participants 3 messages Dec 19, 2016 – Dec 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dev-tools: Added script for updating copyright years in files

Very simple tool which modifies the Copyright lines in all git checked-in files with an updated year. Lines only listing a single year (2016) will be modified to list a range instead.

Only the Copyright lines owners of specific owners will be modified. The script will need to be slightly updated to cover more owners. See the UPDATE_COPYRIGHT_LINES line in the script for the currently set owners.

---
 dev-tools/update-copyright.sh | 50 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100755 dev-tools/update-copyright.sh
dev-tools/update-copyright.sh new file +50 -0
new file mode 100755
index 0000000..26486ec
@@ -0,0 +1,50 @@
+#!/bin/sh
+# update-copyright-sh - Simple tool to update the Copyright lines
+#                       in all files checked into git
+#
+# Copyright (C) 2016 David Sommerseth <[email protected]...>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+# Basic shell sanity
+set -eu
+
+# Simple argument control
+if [ $# -ne 1 ]; then
+    echo "Usage: $0 <New Copyright Year>"
+    exit 1
+fi
+
+# Only update Copyright lines with these owners
+# The 'or' operator is GNU sed specific, and must be \|
+UPDATE_COPYRIGHT_LINES="@openvpn\.net\|@fox-it\.com\|@eurephia\.net\|@greenie\.muc\.de"
+COPY_YEAR="$1"
+
+cd "$(git rev-parse --show-toplevel)"
+for file in $(git ls-files | grep -v cmocka);
+do
+    echo -n "Updating $file ..."
+    # The first sed operation covers 20xx-20yy copyright lines,
+    # The second sed operation changes 20xx -> 20xx-20yy
+    sed -e "/$UPDATE_COPYRIGHT_LINES/s/\(Copyright (C) 20..-\)\(20..\)[[:blank:]]\+/\1$COPY_YEAR /" \
+        -e "/$UPDATE_COPYRIGHT_LINES/s/\(Copyright (C) \)\(20..\)[[:blank:]]\+/\1\2-$COPY_YEAR /" \
+        -i $file
+    echo " Done"
+done
+echo
+echo "** All files updated with $COPY_YEAR as the ending copyright year"
+echo
+exit 0
Signature · 1 line
1.8.3.1
#1 lore raw

Hi,

Quoted 3 lines · David Sommerseth

Very simple tool which modifies the Copyright lines in all git checked-in files with an updated year. Lines only listing a single year (2016) will be modified to list a range instead.

Good idea.

Quoted 1 line

+for file in $(git ls-files | grep -v cmocka);

Should 'cmocka' here be just 'vendor/'?

Otherwise this looks good to me, so once you've considered the above, ACK.

-Steffan

#2 lore raw
In reply to David Sommerseth

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've done a quick update to the patch at commit time. As suggested by Steffan, I've changed from excluding cmocka to exclude vendor/. In addition @sophos.com copyright lines will also be included in this update.

If anyone else wants to be included in these updates, please let us know and we will update the script accordingly.

Your patch has been applied to the following branches

commit da8f11f895bb78174d4412d82a6992c398da495a  (master)
commit 0b159a62ed1c9d60e0c7001b025d2d016a90057f  (release/2.4)
commit 9e2bbbc7bc9bb126ed1061cf0c2ee2fb5ffc919d  (release/2.3)
Author: David Sommerseth
Date:   Mon Dec 19 19:52:12 2016 +0100
     dev-tools: Added script for updating copyright years in files

     Signed-off-by: David Sommerseth <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg13645.html

- --
kind regards,

David Sommerseth

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJYWm4lAAoJEIbPlEyWcf3ydKgQAKaAAAXh9G+FqkyCXRdNxR0X R4WQqI6oU+uejUqg2EXQYPp/xfBuqZM+k7XlzqMpsHR7YRnEHSb30gRxokFdHdwa o1fBnDy1GWl+y+ZpFwnVTfwX2pu+6eoxqxku7eiMFrQayzZnm0P9Y+Aq4PrL3OWl 1nwS5zPO3YkAW7KNCDK+7pXXqLNINI3Pj6LdfAoAEOeXK3Qi1umgdFTwh1nGCq5J xnXTn6b0aF8aURqjRnA51Sz3Pg36YquA7nuoP7AiGGlmD3ctiys4QCOYdjPk0Qs8 aliYHvtRMeNhfiH3SjIixY+J0Mk0EUqP0AXPUu6YvdJ99tzyGhhgcpcS+pHkC1cF 9iyLpKPwpKG4cVbsqhMw7WDkZZqCxxfDkUd0i64nt3T35IaLjkwDq1Bw6KAeREs2 sRT8ptrq7u4b+X34xdU3ah/dgl7KXzYk03A7bhrkopvZpnxlEPQ2nljhk0duu1lB mv9Af0be4lSN+4WOo8XPrpnlc0o24oKDErjyHsfbVjI1mcl1hhqjUCz7XH4qP2/e Iqjh9rQG2mbl0d8IiVhZpowHHB5EKjQ8XjxOHXZ9YBKYy1WiHC5bOOZAMaBupJk6 sUN7THfoPbbMG5kWMQdogeW27Fuqvx5G3UfuMmesTgkwgRMPUtRaELMgQLaP6raM RbAG5ScQAowiLsCrOaiT
=YMgD
-----END PGP SIGNATURE-----