Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-07 20:57:35 +0300
committerDouwe Maan <douwe@gitlab.com>2017-06-07 20:57:35 +0300
commit4cb619fd73fbdfe174497e39a2a655c1896e21d7 (patch)
tree1c77b4902237bf3fe9d734c01071639c093c7111 /lib
parent1136c0c81a079e5de9321245c9b00a7ab61c30e6 (diff)
parent223b87d7b1eccfc844631118e454c69a6312004d (diff)
Merge branch 'backport_fix_slash_commands_for_multiple_assignee' into 'master'
Backport from EE: Fix '/unassign' slash command See merge request !11926
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/slash_commands/command_definition.rb10
-rw-r--r--lib/gitlab/slash_commands/dsl.rb4
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/slash_commands/command_definition.rb b/lib/gitlab/slash_commands/command_definition.rb
index 12a385f90fd..caab8856014 100644
--- a/lib/gitlab/slash_commands/command_definition.rb
+++ b/lib/gitlab/slash_commands/command_definition.rb
@@ -48,17 +48,23 @@ module Gitlab
end
def to_h(opts)
+ context = OpenStruct.new(opts)
+
desc = description
if desc.respond_to?(:call)
- context = OpenStruct.new(opts)
desc = context.instance_exec(&desc) rescue ''
end
+ prms = params
+ if prms.respond_to?(:call)
+ prms = Array(context.instance_exec(&prms)) rescue params
+ end
+
{
name: name,
aliases: aliases,
description: desc,
- params: params
+ params: prms
}
end
diff --git a/lib/gitlab/slash_commands/dsl.rb b/lib/gitlab/slash_commands/dsl.rb
index 614bafbe1b2..1b5b4566d81 100644
--- a/lib/gitlab/slash_commands/dsl.rb
+++ b/lib/gitlab/slash_commands/dsl.rb
@@ -40,8 +40,8 @@ module Gitlab
# command :command_key do |arguments|
# # Awesome code block
# end
- def params(*params)
- @params = params
+ def params(*params, &block)
+ @params = block_given? ? block : params
end
# Allows to give an explanation of what the command will do when