aboutsummaryrefslogtreecommitdiff
path: root/tools/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hooks')
-rwxr-xr-xtools/hooks/pre-commit.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/hooks/pre-commit.rb b/tools/hooks/pre-commit.rb
new file mode 100755
index 0000000..83b4978
--- /dev/null
+++ b/tools/hooks/pre-commit.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+
+result = 0
+files = Dir['src/**/*.h'] + Dir['src/**/*.cpp'] - Dir['src/3rd-party/**/*']
+
+puts 'Checking licenses...'
+files.each { |name|
+ File.open(name) { |f|
+ if not f.readline.start_with? '/** LICENSE **' then
+ puts "Missing license header: #{name}"
+ result = 1
+ end
+ }
+}
+
+puts 'Checking style...'
+if not `astyle --dry-run --formatted --options=astyle.rc #{files.join(' ')}`.empty? then
+ system "astyle --verbose --formatted --options=astyle.rc #{files.join(' ')}"
+ result = 1
+end
+
+puts "pre-commit exit(#{result})"
+exit result