diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-03-23 13:30:29 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-03-23 13:30:29 +0100 |
commit | 3149525c2bb845b5440c9749acded484d009e6ac (patch) | |
tree | dd8b69183b067f24057728ace06b25f707cce5f8 /tools | |
parent | Blocker fixes (diff) | |
download | smolbote-3149525c2bb845b5440c9749acded484d009e6ac.tar.xz |
Rewrote the pre-commit hook into Ruby
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/hooks/pre-commit.rb | 23 | ||||
-rw-r--r-- | tools/qbs/GitRepo.js | 15 |
2 files changed, 38 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 diff --git a/tools/qbs/GitRepo.js b/tools/qbs/GitRepo.js new file mode 100644 index 0000000..d7e19a7 --- /dev/null +++ b/tools/qbs/GitRepo.js @@ -0,0 +1,15 @@ +var Process = loadExtension("qbs.Process") + +function read(workingDirectory) { + var git = new Process(); + git.setWorkingDirectory(workingDirectory); + + var meta = Object.create(null); + git.exec("git", ["describe", "--abbrev=0", "--tag"], true); + meta.version = git.readLine(); + + git.exec("git", ["describe", "--tag"], true); + meta.describe = git.readLine(); + + return meta; +} |