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
|
# File 'lib/cocoapods-hbh/git_hooks/githooks_sync.rb', line 6
def sync
return unless HBHConfig.config.is_git_hooks
Pod::UI.puts "开始同步git拦截设置"
if !File.directory?(".git")
Pod::UI.puts "没有发现git工程"
return
end
git_hooks = "#{File.dirname(__FILE__)}/../../script_source/pre-commit"
git_hooks = '.git-hooks/.' unless Dir['.git-hooks/*'].empty?
if !File.directory?(".git/hooks")
FileUtils.mkdir ".git/hooks"
end
FileUtils.cp_r(git_hooks, ".git/hooks/")
path = ".git/hooks/"
Dir.open(path).each do |p|
filename = File.basename(p, File.extname(p))
if File.extname(p) == ".sh"
FileUtils.mv("#{path}/#{p}", "#{path}/#{filename}")
end
FileUtils.chmod("+x", "#{path}/#{filename}")
end
Pod::UI.puts "结束同步git拦截设置"
end
|