From 78b1278317d77dd79b66ea2b15c38d478e38b538 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Fri, 10 Jan 2020 12:40:25 +0100 Subject: [PATCH] #959 - Added Bash scripts to update the copyright years of Java source files. Usage is described by executing the scripts without parameters. --- etc/scripts/branch-update-license-headers | 27 +++++++++++++++++++++++ etc/scripts/new-issue-branch | 2 +- etc/scripts/update-license-headers | 9 ++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 etc/scripts/branch-update-license-headers create mode 100755 etc/scripts/update-license-headers diff --git a/etc/scripts/branch-update-license-headers b/etc/scripts/branch-update-license-headers new file mode 100755 index 00000000..ba408228 --- /dev/null +++ b/etc/scripts/branch-update-license-headers @@ -0,0 +1,27 @@ +#!/bin/bash +# +# This script updates the license headers of Java files to extend the copyright year to given date and commits those using the given message to all branches listed +USAGE="$0 " +if [ $# -lt 1 ]; then echo -e "ERROR: Year required. \n$USAGE" >&2; exit 1; fi +if [ $# -lt 2 ]; then echo -e "ERROR: Commit message required.\n$USAGE" >&2; exit 1; fi +if [ $# -lt 3 ]; then echo -e "ERROR: At least one branch required.\n$USAGE" >&2; exit 1; fi + +YEAR="$1" +MESSAGE="$2" +shift 2 + +git fetch + +PUSHSPEC="" +for branch in "$@" +do + echo "Processing branch $branch" + git checkout $branch + git rebase origin/$branch + update-license-headers.sh $YEAR + git add *.java + git commit -m "$MESSAGE" + PUSHSPEC="${PUSHSPEC} $branch" +done + +echo pushing $PUSHSPEC diff --git a/etc/scripts/new-issue-branch b/etc/scripts/new-issue-branch index ffbddec1..8aa2c411 100755 --- a/etc/scripts/new-issue-branch +++ b/etc/scripts/new-issue-branch @@ -3,7 +3,7 @@ # This script creates a new local issue branch for the given issue id. # Previous changes are stashed before the issue branch is created and are reapplied after branch creation. # -# executing new-issue-branch.sh DATACMNS-42 +# executing new-issue-branch DATACMNS-42 # will create a new (local) branch issue/DATACMNS-42 USAGE="$0 " if [ $# -lt 1 ]; then echo -e "ERROR: ticket_id required. \n$USAGE" >&2; exit 1; fi diff --git a/etc/scripts/update-license-headers b/etc/scripts/update-license-headers new file mode 100755 index 00000000..b8574de8 --- /dev/null +++ b/etc/scripts/update-license-headers @@ -0,0 +1,9 @@ +#!/bin/bash +# +# This script updates the license headers of all Java files to extend the copyright year to the given date. +USAGE="$0 " +if [ $# -lt 1 ]; then echo -e "ERROR: Year required. \n$USAGE" >&2; exit 1; fi + +YEAR=$1 +for file in `find . -name '*.java' `; do sed -E -i '' "s/\* Copyright ([0-9]{4})-([0-9]{4}) the/\* Copyright \1-${YEAR} the/g" $file; done +for file in `find . -name '*.java' `; do sed -E -i '' "s/\* Copyright ([0-9]{4}) the/\* Copyright \1-${YEAR} the/g" $file; done