Utils fixes

This commit is contained in:
Andre Richter 2019-12-30 23:28:48 +01:00
parent fad90e8bb1
commit e5bfd30477
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E
4 changed files with 7 additions and 7 deletions

View File

@ -13,6 +13,6 @@ staged_files = `git --no-pager diff --name-only --cached`.split(/\n/)
staged_files.each do |f| staged_files.each do |f|
if f.include?('Makefile') || source_files_exts.include?(File.extname(f)) if f.include?('Makefile') || source_files_exts.include?(File.extname(f))
puts "Checking for copyright range: #{f}" puts "Checking for copyright range: #{f}"
exit 1 unless copyrighted?(f, true) exit 1 unless copyrighted?(f)
end end
end end

View File

@ -11,9 +11,9 @@ def checkin_years(file)
checkin_years.split(/\n/).map!(&:to_i) checkin_years.split(/\n/).map!(&:to_i)
end end
def parse_checkin_years(file, is_being_checked_in) def parse_checkin_years(file)
checkin_years = checkin_years(file) checkin_years = checkin_years(file)
checkin_years << Time.now.year if is_being_checked_in checkin_years << Time.now.year
checkin_years.minmax checkin_years.minmax
end end
@ -38,8 +38,8 @@ def print_on_err(file, copyright_lines, checkin_min, checkin_max)
puts "\tMax year: " + checkin_max.to_s puts "\tMax year: " + checkin_max.to_s
end end
def copyrighted?(file, is_being_checked_in) def copyrighted?(file)
checkin_min, checkin_max = parse_checkin_years(file, is_being_checked_in) checkin_min, checkin_max = parse_checkin_years(file)
copyright_lines = File.readlines(file).grep(/.*Copyright.*/) copyright_lines = File.readlines(file).grep(/.*Copyright.*/)
min_seen, max_seen = min_max_seen?(copyright_lines, checkin_min, checkin_max) min_seen, max_seen = min_max_seen?(copyright_lines, checkin_min, checkin_max)

View File

@ -11,7 +11,7 @@ WITH_EXTRA = '[X0-9]'
NO_EXTRA = '[0-9]' NO_EXTRA = '[0-9]'
def tutorial_folders(with_extra = true) def tutorial_folders(with_extra = true)
crates = Dir['**/Cargo.toml'] crates = Dir['*/Cargo.toml']
crates.delete_if do |x| crates.delete_if do |x|
s = with_extra ? WITH_EXTRA : NO_EXTRA s = with_extra ? WITH_EXTRA : NO_EXTRA

View File

@ -29,7 +29,7 @@ def check_old_copyrights
sources.sort.each do |f| sources.sort.each do |f|
puts "Checking for copyright: #{f}" puts "Checking for copyright: #{f}"
exit(1) unless copyrighted?(f, false) exit(1) unless copyrighted?(f)
end end
end end