Class: GitHooksService

Inherits:
Object
  • Object
show all
Defined in:
app/services/git_hooks_service.rb

Constant Summary collapse

PreReceiveError =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#execute(user, repo_path, oldrev, newrev, ref) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/git_hooks_service.rb', line 4

def execute(user, repo_path, oldrev, newrev, ref)
  @repo_path  = repo_path
  @user       = Gitlab::ShellEnv.gl_id(user)
  @oldrev     = oldrev
  @newrev     = newrev
  @ref        = ref

  %w(pre-receive update).each do |hook_name|
    unless run_hook(hook_name)
      raise PreReceiveError.new("Git operation was rejected by #{hook_name} hook")
    end
  end

  yield

  run_hook('post-receive')
end