Class: PostReceive

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

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/workers/post_receive.rb', line 19

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 SidekiqLogArguments.enabled?
  post_received = Gitlab::GitPostReceive.new(container, identifier, changes, push_options)

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