aboutsummaryrefslogtreecommitdiff
path: root/tools/hooks/pre-commit.rb
blob: 825a851dc87424ba233ab3e99b3af4d48545d031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env ruby

result = 0
files = Dir.glob("src/**/*.h") + Dir.glob("src/**/*.cpp") + Dir.glob("lib/**/*.h") + Dir.glob("lib/**/*.cpp")

puts "pre-commit: #{`pwd`}"

puts 'Checking licenses...'
files.each { |name|
    File.open(name) { |file|
        if file.grep(/SPDX-License-Identifier/).empty? then
            puts "Missing or incorrect license header: #{name}"
            result = 1
        end
    }
}

puts "pre-commit exit(#{result})"
exit result