diff options
author | Nick Thomas <nick@gitlab.com> | 2019-06-19 15:34:16 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-06-19 15:34:16 +0300 |
commit | 7277c9b0681186aea3e67ef7ec2dc2b597b5a98c (patch) | |
tree | d5512428af12d6fe5f36c4f8d07f6e3ad23cb9e9 /app/workers | |
parent | 5740dccd126423b9277818fced559884ef9fed4d (diff) | |
parent | 39ec4d1c2824dafccc0d59bd0cfa3abce7d9154c (diff) |
Merge branch 'ce-12014-incremental-es-wiki-updates' into 'master'
Backport of 12014-incremental-es-wiki-updates
See merge request gitlab-org/gitlab-ce!29531
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/post_receive.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index 3f1639ec2ed..dba7837bd12 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -30,15 +30,17 @@ class PostReceive private + def identify_user(post_received) + post_received.identify.tap do |user| + log("Triggered hook for non-existing user \"#{post_received.identifier}\"") unless user + end + end + def process_project_changes(post_received) changes = [] refs = Set.new - @user = post_received.identify - - unless @user - log("Triggered hook for non-existing user \"#{post_received.identifier}\"") - return false - end + user = identify_user(post_received) + return false unless user post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index| service_klass = @@ -51,7 +53,7 @@ class PostReceive if service_klass service_klass.new( post_received.project, - @user, + user, oldrev: oldrev, newrev: newrev, ref: ref, @@ -64,7 +66,7 @@ class PostReceive refs << ref end - after_project_changes_hooks(post_received, @user, refs.to_a, changes) + after_project_changes_hooks(post_received, user, refs.to_a, changes) end def after_project_changes_hooks(post_received, user, refs, changes) @@ -76,6 +78,11 @@ class PostReceive post_received.project.touch(:last_activity_at, :last_repository_updated_at) post_received.project.wiki.repository.expire_statistics_caches ProjectCacheWorker.perform_async(post_received.project.id, [], [:wiki_size]) + + user = identify_user(post_received) + return false unless user + + ::Git::WikiPushService.new(post_received.project, user, changes: post_received.enum_for(:changes_refs)).execute end def log(message) |