lib/gitlab_reviewbot/plugin.rb in danger-gitlab_reviewbot-1.0.1 vs lib/gitlab_reviewbot/plugin.rb in danger-gitlab_reviewbot-1.0.2
- old
+ new
@@ -47,14 +47,10 @@
attr_accessor :strategy
def strategy
@strategy || Danger::AssignStrategies::RandomStrategy
end
- # Add verbosity to the logs
- # @return Bool
- attr_accessor :verbose
-
# Call this method from the Dangerfile to assign reviewers to your merge requests
# @return The usernames list of assigned reviewes [Array<String>]
#
def assign!
project_id = ENV['CI_PROJECT_ID']
@@ -65,26 +61,28 @@
if project_id.nil?
raise "Env variable CI_PROJECT_ID doesn't point to a valid project id"
end
- current_assignees = (ENV['CI_MERGE_REQUEST_ASSIGNEES'] || '').split(',')
- required_assignees_count = [assignees_amount - current_assignees.length, 0].max
+ current_assignees = (ENV['CI_MERGE_REQUEST_ASSIGNEES'] || '').split(',') #buggy?
+ already_assigned_count = current_assignees.length
+ required_assignees_count = [assignees_amount - already_assigned_count, 0].max
- puts "Project ID: #{project_id}" if @verbose
- puts "MR IID: #{mr_iid}" if @verbose
- puts "Currently assigned: #{current_assignees}" if @verbose
- puts "Required: #{required_assignees_count}" if @verbose
- if required_assignees_count == 0
- puts "Nothing to do" if @verbose
- return
- end
+ puts "Project ID: #{project_id}" if verbose
+ puts "MR IID: #{mr_iid}" if verbose
+ puts "Currently assigned: #{current_assignees}" if verbose
+ # puts "Required: #{required_assignees_count}" if @verbose
+ # if required_assignees_count == 0
+ # puts "Nothing to do" if @verbose
+ # return
+ # end
+
strategy_class = strategy.new(client: gitlab.api, project: project_id, mr: mr_iid, group: gitlab_group)
assignees = strategy_class.assign! assignees_amount
- puts "Assigning: #{assignees}" if @verbose
+ puts "Assigning: #{assignees}" if verbose
return assignees
end
end
end