-
Notifications
You must be signed in to change notification settings - Fork 12
/
Rakefile
46 lines (39 loc) · 1.33 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'fileutils'
require 'pathname'
require 'bundler/gem_tasks'
require 'rainbow'
require 'rake/testtask'
require 'rubocop/rake_task'
require 'yard'
import 'tasks/shellcraft/x86.rake'
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb', 'tasks/**/*.rake', 'test/**/*.rb']
end
task default: %i(install_git_hooks rubocop test)
Rake::TestTask.new(:test) do |test|
test.libs << 'lib'
test.libs << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
test.options = '--pride'
end
YARD::Rake::YardocTask.new(:doc)
task :install_git_hooks do
next if ENV['CI']
hooks = %w(pre-push)
git_hook_dir = Pathname.new('.git/hooks/')
hook_dir = Pathname.new('git-hooks/')
hooks.each do |hook|
src = hook_dir + hook
target = git_hook_dir + hook
next if target.symlink? && (target.dirname + target.readlink).realpath == src.realpath
puts "Installing git hook #{hook}..."
target.unlink if target.exist? || target.symlink?
target.make_symlink(src.relative_path_from(target.dirname))
end
git_version = `git version`[/\Agit version (.*)\Z/, 1]
if Gem::Version.new(git_version) < Gem::Version.new('1.8.2')
puts Rainbow("Your git is older than 1.8.2, and doesn't support pre-push hook...").bright.red
puts Rainbow('Please make sure test passed before pushing!!!!!!').bright.red
end
end