community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1733858 - /comdev/tools/licensing/report_notice_copyright_year.pl
Date Mon, 07 Mar 2016 01:35:14 GMT
Author: rvs
Date: Mon Mar  7 01:35:13 2016
New Revision: 1733858

URL: http://svn.apache.org/viewvc?rev=1733858&view=rev
Log:
Helper script to scan a project's SVN, find NOTICE files, determine with 'svn info' if code
below it has changed, and report whether the copyright year needs to be updated. Cocoon, Forrest,
and perhaps other projects, have many NOTICE files associated with plugins or blocks.

Added:
    comdev/tools/licensing/report_notice_copyright_year.pl   (with props)

Added: comdev/tools/licensing/report_notice_copyright_year.pl
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/report_notice_copyright_year.pl?rev=1733858&view=auto
==============================================================================
--- comdev/tools/licensing/report_notice_copyright_year.pl (added)
+++ comdev/tools/licensing/report_notice_copyright_year.pl Mon Mar  7 01:35:13 2016
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+# 
+#       http://www.apache.org/licenses/LICENSE-2.0
+# 
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+#########################################################################
+# Description:
+# Scan an SVN working copy and report any NOTICE files that need the
+# copyright year to be updated because the code below it has changed.
+#
+# Procedure:
+#  cd to the directory of interest.
+#  svn update
+#  Run this script.
+#  Finds all NOTICE files and uses 'svn info" to determine if code has changed.
+#  Review the output for "MODIFY" notes.
+#  Edit the relevant files manually and commit.
+#
+#########################################################################
+
+use strict;
+use File::Basename;
+
+my @inputList = `find . -name "*NOTICE*" -print`;
+my ($totalCount, $yearMissingCount, $yearCurrentCount, $yearChangedCount) = (0, 0, 0, 0);
+my $currentYear = 1900 + (localtime)[5];
+foreach my $inputFn (@inputList) {
+  next if $inputFn =~ /\.svn/;
+  next if $inputFn =~ /\/build\//;
+  next if $inputFn =~ /\.swp$/;
+  next if $inputFn =~ /~$/;
+  next if $inputFn =~ /\/lib\//; # probably notice files of supporting products
+  chomp($inputFn);
+  $totalCount++;
+  my $existingYear = "";
+  open(INPUT, "<$inputFn") or die "Could not open input file '$inputFn': $!";
+  while (<INPUT>) {
+    if (/Copyright [0-9]*-?([0-9]{4}) The Apache/) {
+      $existingYear = $1;
+      last;
+    }
+  }
+  close INPUT;
+  
+  # get the last changed date via 'svn info'
+  my $dirname = dirname($inputFn);
+  my $changed = `svn info $dirname | grep "Last Changed Date"`;
+  $changed =~ /([0-9]{4})-([0-9]{2}-[0-9]{2})/;
+  my $changedYear = $1;
+
+  print "$inputFn : existingYear=$existingYear svnChangedDate=$1-$2";
+  if ($existingYear eq "") { $yearMissingCount++; }
+  elsif ($changedYear > $existingYear) {
+    print " MODIFY";
+    $yearChangedCount++;
+  }
+  elsif ($existingYear == $currentYear) {
+    $yearCurrentCount++;
+  }
+  print "\n";
+}
+
+print qq!
+There was a total of $totalCount NOTICE files.
+$yearMissingCount were missing the copyright year line.
+$yearCurrentCount have current copyright year.
+$yearChangedCount need to be changed to the current year $currentYear.
+!;

Propchange: comdev/tools/licensing/report_notice_copyright_year.pl
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message