Module: Meathook
- Defined in:
- lib/meathook.rb,
lib/meathook/hook.rb,
lib/meathook/captain.rb,
lib/meathook/command.rb
Defined Under Namespace
Classes: Captain, Command, Hook
Constant Summary
collapse
- RECOGNIZED_HOOKS =
[
"applypatch-msg",
"pre-applypatch",
"post-applypatch",
"pre-commit",
"prepare-commit-msg",
"commit-msg",
"post-commit",
"pre-rebase",
"post-checkout",
"post-merge",
"pre-receive",
"update",
"post-receive",
"post-update",
"pre-auto-gc",
"post-rewrite",
]
Class Method Summary
collapse
Class Method Details
.install(xname) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/meathook.rb', line 22
def self.install(xname)
RECOGNIZED_HOOKS.each do |name|
path = ".git/hooks/#{name}"
hook_contents = File.exist?(path) ? File.read(path) : ""
unless hook_contents =~ /#{xname} execute/
system("echo '#{xname} execute #{name} #MEATHOOK' >> '#{path}'")
system("chmod +x '#{path}'")
end
end
end
|
.uninstall(xname) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/meathook.rb', line 33
def self.uninstall(xname)
RECOGNIZED_HOOKS.each do |name|
path = ".git/hooks/#{name}"
hook_contents = File.exist?(path) ? File.read(path) : ""
if hook_contents =~ /#{xname} execute/
system("sed -i '.bak' '/MEATHOOK/d' '#{path}'")
end
end
end
|