Module: ModuleSync::Hook
- Includes:
- Constants
- Defined in:
- lib/modulesync/hook.rb
Constant Summary
Constants included
from Constants
Constants::CONF_FILE, Constants::GLOBAL_DEFAULTS_KEY, Constants::HOOK_FILE, Constants::MODULESYNC_CONF_FILE, Constants::MODULE_CONF_FILE, Constants::MODULE_FILES_DIR
Class Method Summary
collapse
Class Method Details
.activate(args) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/modulesync/hook.rb', line 5
def self.activate(args)
repo = args[:configs]
hook_args = ''
hook_args <<= " -n #{args[:namespace]}" if args[:namespace]
hook_args <<= " -b #{args[:branch]}" if args[:branch]
hook = "#!/usr/bin/env bash\n\ncurrent_branch=\\`git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,'\\`\ngit_dir=\\`git rev-parse --show-toplevel\\`\nmessage=\\`git log -1 --format=%B\\`\nmsync -m \"\\$message\"\#{hook_args}\n"
File.open("#{repo}/#{HOOK_FILE}", 'w') do |file|
file.write(hook)
end
end
|
.deactivate(repo) ⇒ Object
23
24
25
26
|
# File 'lib/modulesync/hook.rb', line 23
def self.deactivate(repo)
hook_path = "#{repo}/#{HOOK_FILE}"
File.delete(hook_path) if File.exists?(hook_path)
end
|
.hook(command, args) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/modulesync/hook.rb', line 28
def self.hook(command, args)
if (command == 'activate')
activate(args)
else
deactivate(args[:configs])
end
end
|