diff options
-rwxr-xr-x | tools/check_license.rb | 22 | ||||
-rwxr-xr-x | tools/fix_headers.rb | 18 | ||||
-rwxr-xr-x | tools/gen_authors.sh | 22 | ||||
-rwxr-xr-x | tools/hooks/pre-commit.rb | 9 |
4 files changed, 25 insertions, 46 deletions
diff --git a/tools/check_license.rb b/tools/check_license.rb deleted file mode 100755 index 66cb0f1..0000000 --- a/tools/check_license.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env ruby - -exit_code = 0 -file_names = Dir.glob("**/*.h") + Dir.glob("**/*.cpp") - -puts "Running in #{`pwd`}" - -# for each item in file_names -file_names.each do |file_name| - File.open(file_name) { |file| - if file.grep(/SPDX-License-Identifier/).empty? then - puts "Missing or incorrect license header: #{file_name}" - exit_code = 1 - end - } -end - -if exit_code == 0 then - puts "All licenses okay" -end - -exit exit_code diff --git a/tools/fix_headers.rb b/tools/fix_headers.rb deleted file mode 100755 index 6d23ed6..0000000 --- a/tools/fix_headers.rb +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/ruby - - # for all files - -file_names = Dir.glob("**/*.h") + Dir.glob("**/*.cpp") -new_header = File.read('new_header') -old_header = File.read('old_header') - -file_names.each do |file_name| - text = File.read(file_name) - new_contents = text.gsub(old_header, new_header) - - # To merely print the contents of the file, use: - #puts new_contents - - # To write changes to the file, use: - File.open(file_name, "w") {|file| file.puts new_contents } -end diff --git a/tools/gen_authors.sh b/tools/gen_authors.sh new file mode 100755 index 0000000..4f69c76 --- /dev/null +++ b/tools/gen_authors.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Generate a list of everyone who has contributed to the project merging those +# who commited under two names or email addresses. +# Original: https://github.com/Arora/arora/blob/master/generateAuthors +# +# To can pass an arg (which goes to git log) +# Example: to see everyone who contributed between tag 0.6 and now +# ./generateAuthors 0.6..HEAD +# +# Currently this is sorted based on # of commits, sorting contributions is not +# a simple topic as pointed out in this article http://lwn.net/Articles/222773/ +# + +# List of aliases +# Aqua, Aqua-sama <aqua@iserlohn-fortress.net>, Xian Nox, xiannox <xian.nox@gmail.com> + +git log --pretty="format:%an %ae" $1 \ + | sed -e 's/Aqua /Aqua-sama /g'\ + | sed -e 's/Xian Nox xian\.nox@gmail\.com/Aqua-sama aqua@iserlohn-fortress\.net/g'\ + | sort | uniq -c | sort -n -r \ + | sed -e 's/^ *[0-9]* / /g' diff --git a/tools/hooks/pre-commit.rb b/tools/hooks/pre-commit.rb index ffc710c..f93281c 100755 --- a/tools/hooks/pre-commit.rb +++ b/tools/hooks/pre-commit.rb @@ -1,14 +1,14 @@ #!/usr/bin/env ruby result = 0 -files = Dir['src/**/*.h'] + Dir['src/**/*.cpp'] - Dir['src/3rd-party/**/*'] +files = Dir.glob("**/*.h") + Dir.glob("**/*.cpp") -puts "Running in #{`pwd`}" +puts "pre-commit: #{`pwd`}" puts 'Checking licenses...' files.each { |name| File.open(name) { |file| - if file.grep(/Copyright\s\(C\)\s(\d{4}\s*-\s*){0,1}(#{Time.now.year})/).empty? then + if file.grep(/SPDX-License-Identifier/).empty? then puts "Missing or incorrect license header: #{name}" result = 1 end @@ -21,8 +21,5 @@ if not `astyle --dry-run --formatted --options=astyle.rc #{files.join(' ')}`.emp result = 1 end -#puts 'Running cppcheck...' -#`cppcheck --quiet --enable=all --inconclusive --std=posix -I src/ .` - puts "pre-commit exit(#{result})" exit result |