diff options
author | YarNayar <YarTheGreat@gmail.com> | 2017-01-31 16:27:29 +0300 |
---|---|---|
committer | YarNayar <YarTheGreat@gmail.com> | 2017-02-03 13:01:43 +0300 |
commit | 9bb08a7e53b22d7af8484e3921b6fe51996ca981 (patch) | |
tree | 297304815c23591bd2c38d3d2555401b452dfc79 /app/services/slash_commands | |
parent | b525aff665f139cd12ac5a6df78d722427e759cc (diff) |
Adds /target_branch slash command functionality for merge requests
Allows to use slash command /target_branch <target_branch_name> in merge requests notes and description.
Command allows to specify target branch for current merge request.
Proposed in #23619
Diffstat (limited to 'app/services/slash_commands')
-rw-r--r-- | app/services/slash_commands/interpret_service.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb index 3566a8ba92f..3e0a85cf059 100644 --- a/app/services/slash_commands/interpret_service.rb +++ b/app/services/slash_commands/interpret_service.rb @@ -304,6 +304,18 @@ module SlashCommands params '@user' command :cc + desc 'Defines target branch for MR' + params '<Local branch name>' + condition do + issuable.respond_to?(:target_branch) && + (current_user.can?(:"update_#{issuable.to_ability_name}", issuable) || + issuable.new_record?) + end + command :target_branch do |target_branch_param| + branch_name = target_branch_param.strip + @updates[:target_branch] = branch_name if project.repository.branch_names.include?(branch_name) + end + def find_label_ids(labels_param) label_ids_by_reference = extract_references(labels_param, :label).map(&:id) labels_ids_by_name = LabelsFinder.new(current_user, project_id: project.id, name: labels_param.split).execute.select(:id) |