Skip to content
Snippets Groups Projects
Commit 3e7eeefc authored by Douwe Maan's avatar Douwe Maan
Browse files

Address feedback

parent 8b8a4626
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -193,9 +193,7 @@ class IssuableBaseService < BaseService
todo_service.mark_todo(issuable, current_user)
when 'done'
todo = TodosFinder.new(current_user).execute.find_by(target: issuable)
if todo
todo_service.mark_todos_as_done([todo], current_user)
end
todo_service.mark_todos_as_done([todo], current_user) if todo
end
end
 
Loading
Loading
Loading
Loading
@@ -18,11 +18,11 @@ module SlashCommands
 
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]
next unless definition
 
definition.execute(self, opts, *args)
definition.execute(self, opts, args)
end
 
[content, @updates]
Loading
Loading
@@ -76,7 +76,6 @@ module SlashCommands
command :assign do |assignee_param|
user = extract_references(assignee_param, :user).first
user ||= User.find_by(username: assignee_param)
user ||= User.find_by(name: assignee_param)
 
@updates[:assignee_id] = user.id if user
end
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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.
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment