module PrCleaner

Constants

VERSION

Public Instance Methods

clear(repo:, pr_number:, username:) click to toggle source
# File lib/pr_cleaner.rb, line 9
def clear(repo:, pr_number:, username:)
  each_comment_of(repo, pr_number) do |comment|
    next unless comment[:user][:login] == username
    client.delete_pull_request_comment(repo, comment[:id])
  end
end

Private Instance Methods

client() click to toggle source
# File lib/pr_cleaner.rb, line 22
def client
  @client ||= begin
    puts 'Enter your Github login:'
    login = STDIN.gets.chomp
    puts 'Enter your Github password:'
    password = STDIN.noecho(&:gets).chomp

    puts "Removing comments created by #{ARGV[2]}, this may take a while..."

    Octokit::Client.new(login: login, password: password)
  end
end
each_comment_of(repo, pr_number, &blk) click to toggle source
# File lib/pr_cleaner.rb, line 18
def each_comment_of(repo, pr_number, &blk)
  client.pull_request_comments(repo, pr_number).each(&blk)
end