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
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-08-18 02:58:44 +0300
committerDouwe Maan <douwe@selenight.nl>2016-08-18 02:58:44 +0300
commit3e7eeefc939f2ce5234e36684c00b8d1c7e1c7dc (patch)
tree203850462714f28ae4d88654d48bd2ac759f9967 /lib/gitlab/slash_commands
parent8b8a4626c601a13683599fd1a127e2c502af38a3 (diff)
Address feedback
Diffstat (limited to 'lib/gitlab/slash_commands')
-rw-r--r--lib/gitlab/slash_commands/command_definition.rb16
-rw-r--r--lib/gitlab/slash_commands/extractor.rb17
2 files changed, 16 insertions, 17 deletions
diff --git a/lib/gitlab/slash_commands/command_definition.rb b/lib/gitlab/slash_commands/command_definition.rb
index 641c92e77da..2ff8f4eddf0 100644
--- a/lib/gitlab/slash_commands/command_definition.rb
+++ b/lib/gitlab/slash_commands/command_definition.rb
@@ -6,11 +6,11 @@ module Gitlab
def initialize(name, attributes = {})
@name = name
- @aliases = attributes[:aliases] || []
- @description = attributes[:description] || ''
- @params = attributes[:params] || []
- @condition_block = attributes[:condition_block]
- @action_block = attributes[:action_block]
+ @aliases = attributes[:aliases] || []
+ @description = attributes[:description] || ''
+ @params = attributes[:params] || []
+ @condition_block = attributes[:condition_block]
+ @action_block = attributes[:action_block]
end
def all_names
@@ -28,13 +28,13 @@ module Gitlab
context.instance_exec(&condition_block)
end
- def execute(context, opts, *args)
+ def execute(context, opts, args)
return if noop? || !available?(opts)
block_arity = action_block.arity
- return unless block_arity == -1 || block_arity == args.size
+ return unless (args.present? && block_arity == 1) || (args.blank? && block_arity <= 0)
- context.instance_exec(*args, &action_block)
+ context.instance_exec(args, &action_block)
end
def to_h(opts)
diff --git a/lib/gitlab/slash_commands/extractor.rb b/lib/gitlab/slash_commands/extractor.rb
index 02c4c8c492e..c790b825347 100644
--- a/lib/gitlab/slash_commands/extractor.rb
+++ b/lib/gitlab/slash_commands/extractor.rb
@@ -50,15 +50,6 @@ module Gitlab
end
private
-
- def command_names(opts)
- command_definitions.flat_map do |command|
- next if command.noop?
-
- command.all_names
- end.compact
- end
-
# Builds a regular expression to match known commands.
# First match group captures the command name and
# second match group captures its arguments.
@@ -117,6 +108,14 @@ module Gitlab
)
}mx
end
+
+ def command_names(opts)
+ command_definitions.flat_map do |command|
+ next if command.noop?
+
+ command.all_names
+ end.compact
+ end
end
end
end