Class: Commits::CherryPickService

Inherits:
ChangeService show all
Defined in:
app/services/commits/cherry_pick_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from ChangeService

#execute

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #initialize, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#commitObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/commits/cherry_pick_service.rb', line 3

def commit
  cherry_pick_into = @create_merge_request ? @commit.cherry_pick_branch_name : @target_branch
  cherry_pick_tree_id = repository.check_cherry_pick_content(@commit, @target_branch)

  if cherry_pick_tree_id
    create_target_branch(cherry_pick_into) if @create_merge_request

    repository.cherry_pick(current_user, @commit, cherry_pick_into, cherry_pick_tree_id)
    success
  else
    error_msg = "Sorry, we cannot cherry-pick this #{@commit.change_type_title} automatically.
                 It may have already been cherry-picked, or a more recent commit may have updated some of its content."
    raise ChangeError, error_msg
  end
end