diff options
author | Rubén Dávila <ruben@gitlab.com> | 2015-12-01 20:31:44 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2015-12-03 17:39:15 +0300 |
commit | 5e6a5270d52ea2f13ca9967913012691e257439b (patch) | |
tree | 676ccf4b9c1b21b2522cc0b7adf4a9985e04b1fe /app | |
parent | 338eb2c41ea766779d6bb7798079a1dd3a50e11d (diff) |
Raise the exception from #execute instead of #run_hook. #1156 #3069
Diffstat (limited to 'app')
-rw-r--r-- | app/services/git_hooks_service.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/app/services/git_hooks_service.rb b/app/services/git_hooks_service.rb index b7804ed472f..8f5c3393dfc 100644 --- a/app/services/git_hooks_service.rb +++ b/app/services/git_hooks_service.rb @@ -8,23 +8,21 @@ class GitHooksService @newrev = newrev @ref = ref - if run_hook('pre-receive') && run_hook('update') - yield - - run_hook('post-receive') + %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 private def run_hook(name) hook = Gitlab::Git::Hook.new(name, @repo_path) - status = hook.trigger(@user, @oldrev, @newrev, @ref) - - if !status && (name != 'post-receive') - raise PreReceiveError.new("Git operation was rejected by #{name} hook") - end - - status + hook.trigger(@user, @oldrev, @newrev, @ref) end end |