update_copyright_year.sh revision 328
0N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A# This code is free software; you can redistribute it and/or modify it 0N/A# under the terms of the GNU General Public License version 2 only, as 0N/A# published by the Free Software Foundation. 0N/A# This code is distributed in the hope that it will be useful, but WITHOUT 0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A# version 2 for more details (a copy is included in the LICENSE file that 0N/A# accompanied this code). 0N/A# You should have received a copy of the GNU General Public License version 0N/A# 2 along with this work; if not, write to the Free Software Foundation, 0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A# Script to update the Copyright YEAR range in Mercurial sources. 0N/A# (Originally from xdono, Thanks!) 0N/A# This year or supplied year 0N/Aif [
"$1" !=
"" ] ;
then 0N/A# Return true if it makes sense to edit this file 0N/A if [ "$1" != "" -a -f $1 ] ; then 0N/A if [ "${isText}" != "" \ 0N/A -a "${hasCopyright}" != "" \ 0N/A# Update the copyright year on a file 0N/A sed -e "s@\(${copyright} [12][0-9][0-9][0-9],\) [12][0-9][0-9][0-9], ${company}@\1 ${year}, ${company}@" | \ 0N/A sed -e "s@\(${copyright} [12][0-9][0-9][0-9],\) ${company}@\1 ${year}, ${company}@" | \ 0N/A sed -e "s@${copyright} ${year}, ${year}, ${company}@${copyright} ${year}, ${company}@" \ 74N/A# Update the copyright year on all files changed by this changeset 253N/A | ${awk} -F' ' '{for(i=1;i<=NF;i++)print $i}' \ 74N/A if [ -f "${files}" -a -s "${files}" ] ; then 74N/A printf " ERROR: No files changed in the changeset? Must be a mistake.\n" 74N/A | ${awk} -F' ' '{for(i=1;i<=NF;i++)print $i}' 74N/A# Check if repository is clean 223N/A echo "WARNING: This repository contains previously edited working set files." 74N/A# Get all changesets this year 223N/A# Check changeset to see if it is Copyright only changes, filter changesets 74N/A echo "------------------------------------------------" 74N/A if [
"${year}" =
"2010" ] ;
then 64N/A echo "---------------------------------------------" 64N/A echo "Updated the copyright year on a total of ${total} files." 64N/A echo "This count should match the count of modified files in the repository: hg status -m" 64N/A echo "WARNING: This repository contained previously edited working set files." 64N/A echo "---------------------------------------------" 64N/A echo "No files were changed" 64N/A echo "WARNING: This repository contained previously edited working set files."