Second round of Copyright date update
This commit is contained in:
7801
tools/maintenance/2024 Logs/copyright_update_2.log
Normal file
7801
tools/maintenance/2024 Logs/copyright_update_2.log
Normal file
File diff suppressed because it is too large
Load Diff
7799
tools/maintenance/2024 Logs/copyright_update_3.log
Normal file
7799
tools/maintenance/2024 Logs/copyright_update_3.log
Normal file
File diff suppressed because it is too large
Load Diff
7821
tools/maintenance/2024 Logs/copyright_update_4.log
Normal file
7821
tools/maintenance/2024 Logs/copyright_update_4.log
Normal file
File diff suppressed because it is too large
Load Diff
7859
tools/maintenance/2024 Logs/copyright_update_5.log
Normal file
7859
tools/maintenance/2024 Logs/copyright_update_5.log
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,9 +12,12 @@ def update_copyright(file_path, old_copyright, new_copyright)
|
||||
@log.info("Processing file: #{file_path}")
|
||||
@log_file_logger.info("Processing file: #{file_path}")
|
||||
|
||||
case File.extname(file_path)
|
||||
when '.rb', '.js'
|
||||
content = File.read(file_path)
|
||||
# Treat all files the same way for copyright update, including YAML and CSS
|
||||
content = File.read(file_path)
|
||||
if content.empty?
|
||||
@log.info("File is empty, no copyright update needed: #{file_path}")
|
||||
@log_file_logger.info("File is empty, no copyright update needed: #{file_path}")
|
||||
else
|
||||
if content.include?(old_copyright)
|
||||
updated_content = content.gsub(old_copyright, new_copyright)
|
||||
File.write(file_path, updated_content)
|
||||
@@ -24,28 +27,6 @@ def update_copyright(file_path, old_copyright, new_copyright)
|
||||
@log.warn("Copyright string not found in #{file_path}")
|
||||
@log_file_logger.warn("Copyright string not found in #{file_path}")
|
||||
end
|
||||
when '.yaml'
|
||||
yaml_content = YAML.load_file(file_path)
|
||||
if yaml_content && yaml_content['copyright'] == old_copyright
|
||||
yaml_content['copyright'] = new_copyright
|
||||
File.write(file_path, yaml_content.to_yaml)
|
||||
@log.info("Updated copyright in YAML file: #{file_path}")
|
||||
@log_file_logger.info("Updated copyright in YAML file: #{file_path}")
|
||||
else
|
||||
@log.warn("Copyright string not found or incorrect in YAML file: #{file_path}")
|
||||
@log_file_logger.warn("Copyright string not found or incorrect in YAML file: #{file_path}")
|
||||
end
|
||||
when '.html'
|
||||
content = File.read(file_path)
|
||||
if content.include?(old_copyright)
|
||||
updated_content = content.gsub(old_copyright, new_copyright)
|
||||
File.write(file_path, updated_content)
|
||||
@log.info("Updated copyright in HTML file: #{file_path}")
|
||||
@log_file_logger.info("Updated copyright in HTML file: #{file_path}")
|
||||
else
|
||||
@log.warn("Copyright string not found in HTML file: #{file_path}")
|
||||
@log_file_logger.warn("Copyright string not found in HTML file: #{file_path}")
|
||||
end
|
||||
end
|
||||
rescue => e
|
||||
@log.error("Error processing file #{file_path}: #{e.message}")
|
||||
@@ -55,7 +36,15 @@ end
|
||||
old_copyright = 'Copyright (c) 2006-2024'
|
||||
new_copyright = 'Copyright (c) 2006-2025'
|
||||
|
||||
Dir.glob("../../**/*.{rb,js,yaml,html}").each do |file|
|
||||
Dir.glob("../../**/*.{rb,js,yaml,html,md,txt,css,c,nasm,java,php,as}").each do |file|
|
||||
next if File.basename(file) == 'copyright_update.rb' # Skip this file
|
||||
update_copyright(file, old_copyright, new_copyright)
|
||||
end
|
||||
|
||||
# Handle files without extensions, excluding copyright_update.rb
|
||||
Dir.glob("../../**/*").reject { |f|
|
||||
File.directory?(f) || File.extname(f) != '' || File.basename(f) == 'copyright_update.rb'
|
||||
}.each do |file|
|
||||
update_copyright(file, old_copyright, new_copyright)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user