2018-12-29 23:20:24 +00:00
|
|
|
#!/usr/bin/env ruby
|
2019-09-20 13:11:22 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-10-08 07:14:16 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
2019-01-12 18:45:30 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2018-2019 Andre Richter <andre.o.richter@gmail.com>
|
2018-12-29 23:20:24 +00:00
|
|
|
|
2019-09-20 13:11:22 +00:00
|
|
|
require_relative 'helpers/copyrighted'
|
2019-10-08 07:14:16 +00:00
|
|
|
require_relative 'helpers/tutorial_folders.rb'
|
2019-01-12 18:45:30 +00:00
|
|
|
|
|
|
|
def patched?
|
2019-10-17 19:49:38 +00:00
|
|
|
crates = tutorial_folders
|
2018-12-29 23:20:24 +00:00
|
|
|
|
2019-10-17 19:49:38 +00:00
|
|
|
crates.each do |f|
|
|
|
|
unless File.readlines(f).grep(/patch.crates-io/).empty?
|
|
|
|
puts "#{fb} contains patch.crates-io!"
|
|
|
|
exit(1)
|
|
|
|
end
|
2018-12-29 23:20:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-12 18:45:30 +00:00
|
|
|
def check_old_copyrights
|
2019-10-17 19:49:38 +00:00
|
|
|
error = false
|
2019-01-12 18:45:30 +00:00
|
|
|
|
2019-10-17 19:49:38 +00:00
|
|
|
sources = Dir.glob('**/*.{S,rs,rb}') + Dir.glob('**/Makefile')
|
2019-01-12 18:45:30 +00:00
|
|
|
|
2019-10-17 19:49:38 +00:00
|
|
|
sources.delete_if do |x|
|
|
|
|
!system("git ls-files --error-unmatch #{x}", %i[out err] => File::NULL)
|
|
|
|
end
|
2019-01-12 18:45:30 +00:00
|
|
|
|
2019-10-17 19:49:38 +00:00
|
|
|
sources.sort.reverse_each do |f|
|
|
|
|
puts "Checking for copyright: #{f}"
|
|
|
|
error = true unless copyrighted?(f, false)
|
|
|
|
end
|
2019-01-12 18:45:30 +00:00
|
|
|
|
2019-10-17 19:49:38 +00:00
|
|
|
exit(1) if error
|
2019-01-12 18:45:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def sanity_checks
|
2019-10-17 19:49:38 +00:00
|
|
|
patched?
|
|
|
|
check_old_copyrights
|
2018-12-29 23:20:24 +00:00
|
|
|
end
|
2019-01-12 18:45:30 +00:00
|
|
|
|
|
|
|
sanity_checks if $PROGRAM_NAME == __FILE__
|