diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-10-19 10:16:58 +0300 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-11-14 17:16:19 +0300 |
commit | 6b0ea951cac3905437abb2bbacaf422371f097e0 (patch) | |
tree | 55b61f7c3a5a4447fb70733780fca614ac1a73ef /app/services/quick_actions | |
parent | f5e3ce5ed612c9b247e362ed7c667557331e5bfd (diff) |
Creates /create_merge_request quickaction
With this quick action the user can create a new MR starting from
the current issue using as `source_branch` the given `branch name` and
as `target_branch` the project default branch. If the `branch name` is
omitted a name is automatically created starting from the issue title.
Diffstat (limited to 'app/services/quick_actions')
-rw-r--r-- | app/services/quick_actions/interpret_service.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb index 9c81de7e90e..d248b10f41e 100644 --- a/app/services/quick_actions/interpret_service.rb +++ b/app/services/quick_actions/interpret_service.rb @@ -635,6 +635,22 @@ module QuickActions @updates[:tag_message] = message end + desc 'Create a merge request.' + explanation do |branch_name = nil| + branch_text = branch_name ? "branch '#{branch_name}'" : 'a branch' + "Creates #{branch_text} and a merge request to resolve this issue" + end + params "<branch name>" + condition do + issuable.is_a?(Issue) && current_user.can?(:create_merge_request_in, project) && current_user.can?(:push_code, project) + end + command :create_merge_request do |branch_name = nil| + @updates[:create_merge_request] = { + branch_name: branch_name, + issue_iid: issuable.iid + } + end + # rubocop: disable CodeReuse/ActiveRecord def extract_users(params) return [] if params.nil? |