Class: MergeRequests::DeleteSourceBranchWorker

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

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, 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(merge_request_id, source_branch_sha, user_id) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/workers/merge_requests/delete_source_branch_worker.rb', line 14

def perform(merge_request_id, source_branch_sha, user_id)
  merge_request = MergeRequest.find(merge_request_id)
  user = User.find(user_id)

  # Source branch changed while it's being removed
  return if merge_request.source_branch_sha != source_branch_sha

  ::Branches::DeleteService.new(merge_request.source_project, user)
    .execute(merge_request.source_branch)

  ::MergeRequests::RetargetChainService.new(project: merge_request.source_project, current_user: user)
    .execute(merge_request)
rescue ActiveRecord::RecordNotFound
end