Commit 3e7eeefc authored by Douwe Maan's avatar Douwe Maan

Address feedback

parent 8b8a4626
...@@ -193,9 +193,7 @@ class IssuableBaseService < BaseService ...@@ -193,9 +193,7 @@ class IssuableBaseService < BaseService
todo_service.mark_todo(issuable, current_user) todo_service.mark_todo(issuable, current_user)
when 'done' when 'done'
todo = TodosFinder.new(current_user).execute.find_by(target: issuable) todo = TodosFinder.new(current_user).execute.find_by(target: issuable)
if todo todo_service.mark_todos_as_done([todo], current_user) if todo
todo_service.mark_todos_as_done([todo], current_user)
end
end end
end end
......
...@@ -18,11 +18,11 @@ module SlashCommands ...@@ -18,11 +18,11 @@ module SlashCommands
content, commands = extractor.extract_commands(content, opts) content, commands = extractor.extract_commands(content, opts)
commands.each do |name, *args| commands.each do |name, args|
definition = self.class.command_definitions_by_name[name.to_sym] definition = self.class.command_definitions_by_name[name.to_sym]
next unless definition next unless definition
definition.execute(self, opts, *args) definition.execute(self, opts, args)
end end
[content, @updates] [content, @updates]
...@@ -76,7 +76,6 @@ module SlashCommands ...@@ -76,7 +76,6 @@ module SlashCommands
command :assign do |assignee_param| command :assign do |assignee_param|
user = extract_references(assignee_param, :user).first user = extract_references(assignee_param, :user).first
user ||= User.find_by(username: assignee_param) user ||= User.find_by(username: assignee_param)
user ||= User.find_by(name: assignee_param)
@updates[:assignee_id] = user.id if user @updates[:assignee_id] = user.id if user
end end
......
...@@ -28,13 +28,13 @@ module Gitlab ...@@ -28,13 +28,13 @@ module Gitlab
context.instance_exec(&condition_block) context.instance_exec(&condition_block)
end end
def execute(context, opts, *args) def execute(context, opts, args)
return if noop? || !available?(opts) return if noop? || !available?(opts)
block_arity = action_block.arity 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 end
def to_h(opts) def to_h(opts)
......
...@@ -50,15 +50,6 @@ module Gitlab ...@@ -50,15 +50,6 @@ module Gitlab
end end
private 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. # Builds a regular expression to match known commands.
# First match group captures the command name and # First match group captures the command name and
# second match group captures its arguments. # second match group captures its arguments.
...@@ -117,6 +108,14 @@ module Gitlab ...@@ -117,6 +108,14 @@ module Gitlab
) )
}mx }mx
end end
def command_names(opts)
command_definitions.flat_map do |command|
next if command.noop?
command.all_names
end.compact
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment