From 57b867ab36ec5a3a36b25fd7d2e8b4d24919bdbd Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 12 Jan 2024 13:10:56 +0100 Subject: [PATCH] Improve tool/update_copyright.rb --- tool/update_copyright.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tool/update_copyright.rb b/tool/update_copyright.rb index 38745680310b..b1eac2741e7a 100644 --- a/tool/update_copyright.rb +++ b/tool/update_copyright.rb @@ -6,7 +6,7 @@ # GNU General Public License version 2, or # GNU Lesser General Public License version 2.1. -abort "USAGE: ruby #{$0} NEW_YEAR" unless ARGV.first +abort "USAGE: [ADD_ONLY=1] ruby #{$0} NEW_YEAR" unless ARGV.first year = Integer(ARGV.first) new_copyright_year = year @@ -33,11 +33,13 @@ */ EOS +C_COPYRIGHT = JAVA_COPYRIGHT + "\n" + NEW_COPYRIGHT = { '.rb' => RB_COPYRIGHT, '.java' => JAVA_COPYRIGHT, - '.c' => JAVA_COPYRIGHT, - '.h' => JAVA_COPYRIGHT, + '.c' => C_COPYRIGHT, + '.h' => C_COPYRIGHT, } EXTENSIONS = %w[.java .rb .c .h .md] @@ -52,11 +54,13 @@ /Copyright \(c\) \d{4}-\d{4} The JRuby project/, # io/console /Copyright \(C\) \d{4}-\d{4} Wayne Meissner/, # FFI /Copyright \(c\) \d{4}, Brian Shirai/, # rubysl-socket + /Copyright \(c\) \d{4}, \d{4} Todd C\. Miller /, # strlcpy.c /Ruby is copyrighted free software by Yukihiro Matsumoto/, # MRI license /Copyright(?:::)?\s+\(C\)\s+\d{4}\s+Network Applied Communication Laboratory, Inc\./, # MRI stdlibs: thread, timeout /\* BEGIN LICENSE BLOCK \**\s*\n\s*\*\s*Version: EPL 2\.0\/GPL 2\.0\/LGPL 2\.1/, /#+\s*BEGIN LICENSE BLOCK\s*#+\s*\n\s*#\s*Version: EPL 2\.0\/GPL 2\.0\/LGPL 2\.1/, /This file is part of ruby-ffi\./, + /This is a public domain/, ] truffle_paths = %w[ @@ -81,7 +85,6 @@ lib/truffle/pathname lib/truffle/securerandom src/main/c/bigdecimal - src/main/c/cext/st.c src/main/c/date src/main/c/etc src/main/c/io-console @@ -91,7 +94,9 @@ src/main/c/rbconfig-sizeof src/main/c/ripper src/main/c/syslog + src/main/c/yarp src/main/c/zlib + src/yarp spec/truffle/fixtures/hello-world test/truffle/pack-real-usage.rb test/truffle/cexts @@ -115,7 +120,7 @@ excludes.none? { |prefix| path.start_with? prefix } && !excluded_files.include?(File.basename(path)) && File.exist?(path) && - File.readlines(path).size > 2 + File.readlines(path).size > 5 } paths.each do |file| @@ -134,9 +139,12 @@ next end + next if ENV["ADD_ONLY"] + copyright, year1, sep, year2 = $~[:copyright], $~[:year1], $~[:sep], $~[:year2] year1 = Integer(year1) year2 = Integer(year2 || year1) + sep ||= md ? '-' : ', ' if year > year2 contents = File.read(file)