Class: GitHooks::PostReceiveHook

Inherits:
Object
  • Object
show all
Defined in:
lib/git_hooks/post_receive_hook.rb

Instance Method Summary collapse

Constructor Details

#initializePostReceiveHook

Returns a new instance of PostReceiveHook.



4
5
6
# File 'lib/git_hooks/post_receive_hook.rb', line 4

def initialize
  @git_adapter = GitAdapter.new
end

Instance Method Details

#read_arguments_from_stdinObject



17
18
19
20
21
22
23
24
25
# File 'lib/git_hooks/post_receive_hook.rb', line 17

def read_arguments_from_stdin
  arguments = []
  
  while arguments << STDIN.gets
    break if arguments.last.nil?
  end
  
  arguments.compact.first.split(" ")
end

#run(*args) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/git_hooks/post_receive_hook.rb', line 8

def run(*args)
  arguments = read_arguments_from_stdin
  commits   = @git_adapter.find_commits_since_last_receive(*arguments)
  
  GitHooks.config.post_receive_hooks.each do |hook|
    hook.hook_class.deliver(hook.options.merge(:commits => commits))
  end
end