Update copyright year to 2026

This commit is contained in:
zinduolis
2025-12-26 19:18:05 +10:00
parent c308392cb3
commit 95793433fa
1266 changed files with 4204 additions and 1285 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -8,44 +8,46 @@ log_file = File.open('copyright_update.log', 'w')
@log_file_logger = Logger.new(log_file)
@log_file_logger.level = Logger::INFO
def update_copyright(file_path, old_copyright, new_copyright)
def update_copyright(file_path, copyright_pattern, new_copyright)
@log.info("Processing file: #{file_path}")
@log_file_logger.info("Processing file: #{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)
elsif content.match?(copyright_pattern)
updated_content = content.gsub(copyright_pattern, "\\1#{new_copyright}")
if updated_content != content
File.write(file_path, updated_content)
@log.info("Updated copyright in #{file_path}")
@log_file_logger.info("Updated copyright in #{file_path}")
else
@log.warn("Copyright string not found in #{file_path}")
@log_file_logger.warn("Copyright string not found in #{file_path}")
end
else
@log.warn("Copyright pattern not found in #{file_path}")
@log_file_logger.warn("Copyright pattern not found in #{file_path}")
end
rescue => e
@log.error("Error processing file #{file_path}: #{e.message}")
@log_file_logger.error("Error processing file #{file_path}: #{e.message}")
end
old_copyright = 'Copyright (c) 2006-2024'
new_copyright = 'Copyright (c) 2006-2025'
# Regex to match "Copyright (c) 2006-YYYY" or "(C) 2006-YYYY"
# Captures the prefix so we can replace only the year part if needed,
# or better yet, replace the whole match but preserve the "Copyright (c)" part.
copyright_pattern = /((?:Copyright \(c\) |\(C\) )2006-)20\d{2}/
new_year = '2026'
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)
next if File.basename(file) == 'copyright_update.rb'
update_copyright(file, copyright_pattern, new_year)
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)
update_copyright(file, copyright_pattern, new_year)
end
@log.info("Copyright update process completed.")