diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-06-05 20:37:52 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-06-05 20:37:52 -0300 |
commit | 3fd02428d42546bbfc753130e1bc7d1c1f0fa83a (patch) | |
tree | 0817a402d618613aea154dc187322a220f4944ce /app/workers | |
parent | 38b3064c25bcf0aff900969d5cddbc3bde1b106a (diff) | |
download | gitlab-ce-3fd02428d42546bbfc753130e1bc7d1c1f0fa83a.tar.gz |
Refactor PostReceive worker to limit merge conflictsport-post-receive-changes
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 |