diff options
author | Nick Thomas <nick@gitlab.com> | 2017-06-08 03:42:07 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-06-08 03:42:07 +0300 |
commit | bde12f75dcd497ff8afecdc31aa708882e264130 (patch) | |
tree | 613eeef67eb88d3cf97caa2e9e1037c3357d3898 /app/workers | |
parent | be5c1601e4ede6e4283f99742683468abb92a889 (diff) | |
parent | e7f76734b02f3a4665f0fd5848d7e9c2a49807d8 (diff) |
Merge branch 'master' into ce-to-ee-2017-06-07
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/ee/post_receive.rb | 39 | ||||
-rw-r--r-- | app/workers/post_receive.rb | 45 |
2 files changed, 55 insertions, 29 deletions
diff --git a/app/workers/ee/post_receive.rb b/app/workers/ee/post_receive.rb new file mode 100644 index 00000000000..b8f02ec58f6 --- /dev/null +++ b/app/workers/ee/post_receive.rb @@ -0,0 +1,39 @@ +module EE + # PostReceive EE mixin + # + # This module is intended to encapsulate EE-specific model logic + # and be prepended in the `PostReceive` worker + module PostReceive + extend ActiveSupport::Concern + extend ::Gitlab::CurrentSettings + + private + + def after_project_changes_hooks(post_received, user, refs, changes) + super + + # Generate repository updated event on Geo event log when Geo is enabled + ::Geo::RepositoryUpdatedEventStore.new(post_received.project, refs: refs, changes: changes).create + end + + def process_wiki_changes(post_received) + super + + update_wiki_es_indexes(post_received) + + if ::Gitlab::Geo.enabled? + # Create wiki repository updated event on Geo event log + ::Geo::RepositoryUpdatedEventStore.new(post_received.project, source: Geo::RepositoryUpdatedEvent::WIKI).create + + # Triggers repository update on secondary nodes + ::Gitlab::Geo.notify_wiki_update(post_received.project) + end + end + + def update_wiki_es_indexes(post_received) + return unless current_application_settings.elasticsearch_indexing? + + post_received.project.wiki.index_blobs + end + end +end diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index ea771103797..2d37dfdc5dc 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -1,7 +1,7 @@ class PostReceive include Sidekiq::Worker include DedicatedSidekiqQueue - extend Gitlab::CurrentSettings + prepend EE::PostReceive def perform(project_identifier, identifier, changes) project, is_wiki = parse_project_identifier(project_identifier) @@ -18,17 +18,15 @@ class PostReceive post_received = Gitlab::GitPostReceive.new(project, identifier, changes) if is_wiki - update_wiki_es_indexes(post_received) - - # Triggers repository update on secondary nodes when Geo is enabled - Gitlab::Geo.notify_wiki_update(post_received.project) if Gitlab::Geo.enabled? + 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 @@ -40,38 +38,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 - end - def update_wiki_es_indexes(post_received) - return unless current_application_settings.elasticsearch_indexing? + after_project_changes_hooks(post_received, @user, refs.to_a, changes) + end - post_received.project.wiki.index_blobs + 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 - private + 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 |