diff options
author | Jarka Kadlecova <kadlecovaj@gmail.com> | 2016-11-24 17:05:15 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-11 16:48:07 +0300 |
commit | 7ab3dd4b302a85c1b005e9ef290ebac631cda673 (patch) | |
tree | 9210fbc8f4e53c33970e6218c822de95c8963288 /app/services/slash_commands | |
parent | 4404ea8662508c60f96e6730d9a45feb68498c28 (diff) |
support `/merge` slash comand for MRs
Diffstat (limited to 'app/services/slash_commands')
-rw-r--r-- | app/services/slash_commands/interpret_service.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb index d75c5b1800e..14fad3ba120 100644 --- a/app/services/slash_commands/interpret_service.rb +++ b/app/services/slash_commands/interpret_service.rb @@ -2,7 +2,7 @@ module SlashCommands class InterpretService < BaseService include Gitlab::SlashCommands::Dsl - attr_reader :issuable + attr_reader :issuable, :options # Takes a text and interprets the commands that are extracted from it. # Returns the content without commands, and hash of changes to be applied to a record. @@ -13,7 +13,8 @@ module SlashCommands opts = { issuable: issuable, current_user: current_user, - project: project + project: project, + params: params } content, commands = extractor.extract_commands(content, opts) @@ -58,6 +59,17 @@ module SlashCommands @updates[:state_event] = 'reopen' end + desc 'Merge (when build succeeds)' + condition do + last_diff_sha = params.to_h[:merge_request_diff_head_sha] + issuable.is_a?(MergeRequest) && + issuable.mergeable_with_slash_command?(current_user, autocomplete_precheck: !last_diff_sha, last_diff_sha: last_diff_sha) && + issuable.persisted? + end + command :merge do + @updates[:merge] = params[:merge_request_diff_head_sha] + end + desc 'Change title' params '<New title>' condition do |