Class: Hubeye::Hooks::Command
- Inherits:
-
Object
- Object
- Hubeye::Hooks::Command
- Defined in:
- lib/hubeye/hooks/command.rb
Defined Under Namespace
Classes: NoHookError
Class Method Summary collapse
-
.execute(commands, options = {}) ⇒ Object
options include the directory to execute the command and the full repo name of the changed repository.
Class Method Details
.execute(commands, options = {}) ⇒ Object
options include the directory to execute the command and the full repo name of the changed repository
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hubeye/hooks/command.rb', line 9 def self.execute(commands, ={}) opts = {:directory => nil, :repo => nil}.merge() dir = opts[:directory] repo = opts[:repo] begin commands.each do |cmd| if dir Dir.chdir(File.(dir)) do if repo ::Kernel.system "HUBEYE_CHANGED_REPO=#{repo} #{cmd}" else ::Kernel.system cmd end end else ::Kernel.system cmd end end rescue ArgumentError raise NoHookError.new "There aren't any hook commands for the repository #{repo}" end end |