class Octaccord::Command::UpdateIssues

Public Class Methods

new(client, repos, issues, **options) click to toggle source
# File lib/octaccord/command/update_issues.rb, line 6
def initialize(client, repos, issues, **options)
  issues.each do |issue|
    number = issue.to_i
    begin
      if label = options[:add_label]
        response = client.add_labels_to_an_issue(repos, number, [label])
        pp response if options[:debug]
        puts "Add label #{label} to ##{number}."
      end

      if label = options[:remove_label]
        response = client.remove_label(repos, number, label)
        pp response if options[:debug]
        puts "Remove label #{label} from ##{number}."
      end
    rescue Octokit::ClientError => e
      STDERR.puts "Error: ##{issue} -- #{e.message.split(' // ').first}"
    end
  end
end