10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/codeqa.rb', line 10
def install(root='.')
require 'fileutils'
git_root = Pathname.new "#{root}/.git"
if File.exist?(git_root)
pre_commit_path = git_root.join 'hooks', 'pre-commit'
if File.exist?(pre_commit_path)
FileUtils.mv(pre_commit_path,
git_root.join('hooks', 'pre-commit.bkp'),
:force => true)
end
pre_commit_template_path = Codeqa.root.join('lib', 'templates', 'pre-commit')
FileUtils.cp(pre_commit_template_path, pre_commit_path)
FileUtils.chmod('+x', pre_commit_path)
true
else
false
end
end
|