12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/commitphotos.rb', line 12
def self.hook(global, video)
if global
destination = File.expand_path(`git config --get init.templatedir`.chomp)
if destination.empty?
destination = '~/.gittemplates'
mkdir_p(destination) unless File.exist?(destination)
`git config --global init.templatedir #{destination}`
end
else
destination = File.expand_path(File.join(Dir.pwd, '.git/hooks'))
abort 'Error: not a git repository.' unless File.exist? File.join(Dir.pwd, '.git')
end
type = video ? 'video' : 'image'
local_post_commit = "#{File.expand_path(File.dirname(__FILE__))}/commitphotos/hooks/post-commit-#{type}"
FileUtils.mkdir_p(destination)
FileUtils.copy(local_post_commit, File.join(destination, 'post-commit'))
end
|