diff options
author | Robert Speicher <robert@gitlab.com> | 2017-06-08 22:39:28 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-06-08 22:39:28 +0000 |
commit | c28ba5aa72e52182ae002ba3941e25869f69f561 (patch) | |
tree | 2214670eea08fe6c87ee69c46f3ae7b5aea3b11c /app/workers | |
parent | edd8d91194ce79cb5d77973c40436b98eb4d97fc (diff) | |
parent | 3fd02428d42546bbfc753130e1bc7d1c1f0fa83a (diff) | |
download | gitlab-ce-c28ba5aa72e52182ae002ba3941e25869f69f561.tar.gz |
Merge branch 'port-post-receive-changes' into 'master'
Refactor PostReceive worker to limit merge conflicts
See merge request !11916
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/post_receive.rb | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index c29571d3c62..89286595ca6 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -17,14 +17,15 @@ class PostReceive post_received = Gitlab::GitPostReceive.new(project, identifier, changes) if is_wiki - # Nothing defined here yet. + process_wiki_changes(post_received) else process_project_changes(post_received) - process_repository_update(post_received) end end - def process_repository_update(post_received) + private + + def process_project_changes(post_received) changes = [] refs = Set.new @@ -36,32 +37,27 @@ class PostReceive return false end - changes << Gitlab::DataBuilder::Repository.single_change(oldrev, newrev, ref) - refs << ref - end - - hook_data = Gitlab::DataBuilder::Repository.update(post_received.project, @user, changes, refs.to_a) - SystemHooksService.new.execute_hooks(hook_data, :repository_update_hooks) - end - - def process_project_changes(post_received) - post_received.changes_refs do |oldrev, newrev, ref| - @user ||= post_received.identify(newrev) - - unless @user - log("Triggered hook for non-existing user \"#{post_received.identifier}\"") - return false - end - if Gitlab::Git.tag_ref?(ref) GitTagPushService.new(post_received.project, @user, oldrev: oldrev, newrev: newrev, ref: ref).execute elsif Gitlab::Git.branch_ref?(ref) GitPushService.new(post_received.project, @user, oldrev: oldrev, newrev: newrev, ref: ref).execute end + + changes << Gitlab::DataBuilder::Repository.single_change(oldrev, newrev, ref) + refs << ref end + + after_project_changes_hooks(post_received, @user, refs.to_a, changes) end - private + def after_project_changes_hooks(post_received, user, refs, changes) + hook_data = Gitlab::DataBuilder::Repository.update(post_received.project, user, changes, refs) + SystemHooksService.new.execute_hooks(hook_data, :repository_update_hooks) + end + + def process_wiki_changes(post_received) + # Nothing defined here yet. + end # To maintain backwards compatibility, we accept both gl_repository or # repository paths as project identifiers. Our plan is to migrate to |