Class: MergeRequests::RebaseService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/rebase_service.rb

Constant Summary collapse

REBASE_ERROR =
'Rebase failed: Rebase locally, resolve all conflicts, then push the branch.'

Instance Attribute Summary collapse

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods inherited from BaseService

#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_external_hooks, #execute_hooks, #handle_assignees_change, #handle_changes, #handle_reviewers_change, #hook_data, #inspect, #merge_request_activity_counter, #source_project, #target_project

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from AssignsMergeParams

#assign_allowed_merge_params, included

Methods inherited from BaseProjectService

#initialize

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Instance Attribute Details

#merge_requestObject (readonly)

Returns the value of attribute merge_request.


7
8
9
# File 'app/services/merge_requests/rebase_service.rb', line 7

def merge_request
  @merge_request
end

#rebase_errorObject (readonly)

Returns the value of attribute rebase_error.


7
8
9
# File 'app/services/merge_requests/rebase_service.rb', line 7

def rebase_error
  @rebase_error
end

Instance Method Details

#execute(merge_request, skip_ci: false) ⇒ Object


9
10
11
12
13
14
15
16
17
18
# File 'app/services/merge_requests/rebase_service.rb', line 9

def execute(merge_request, skip_ci: false)
  @merge_request = merge_request
  @skip_ci = skip_ci

  if rebase
    success
  else
    error(rebase_error)
  end
end

#rebaseObject


20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/services/merge_requests/rebase_service.rb', line 20

def rebase
  repository.rebase(current_user, merge_request, skip_ci: @skip_ci)

  true
rescue StandardError => e
  set_rebase_error(e)
  log_error(exception: e, message: rebase_error, save_message_on_model: true)

  false
ensure
  merge_request.update_column(:rebase_jid, nil)
end