Class: PostReceive

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/post_receive.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(gl_repository, identifier, changes, push_options = {}) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/workers/post_receive.rb', line 12

def perform(gl_repository, identifier, changes, push_options = {})
  container, project, repo_type = Gitlab::GlRepository.parse(gl_repository)

  if container.nil? || (container.is_a?(ProjectSnippet) && project.nil?)
    log("Triggered hook for non-existing gl_repository \"#{gl_repository}\"")
    return false
  end

  changes = Base64.decode64(changes) unless changes.include?(' ')
  # Use Sidekiq.logger so arguments can be correlated with execution
  # time and thread ID's.
  Sidekiq.logger.info "changes: #{changes.inspect}" if ENV['SIDEKIQ_LOG_ARGUMENTS']
  post_received = Gitlab::GitPostReceive.new(container, identifier, changes, push_options)

  if repo_type.wiki?
    process_wiki_changes(post_received, container.wiki)
  elsif repo_type.project?
    process_project_changes(post_received, container)
  elsif repo_type.snippet?
    process_snippet_changes(post_received, container)
  else
    # Other repos don't have hooks for now
  end
end