Skip to content

Instantly share code, notes, and snippets.

@thephw
Created August 25, 2015 02:18
Show Gist options
  • Save thephw/b1b5acae45726777d5ab to your computer and use it in GitHub Desktop.
Save thephw/b1b5acae45726777d5ab to your computer and use it in GitHub Desktop.
require 'octokit'
ACCESS_TOKEN = "" # Create at https://github.com/settings/tokens
ORGANIZATION_NAME = "SalesLoft"
USER_NAME = "thephw"
PULL_REQUEST_OPTIONS = {state: :all, head: USER_NAME, sort: :created, direction: :desc}
FILTER_AFTER = Time.parse('2015-05-18 00:00:00 UTC')
client = Octokit::Client.new(access_token: ACCESS_TOKEN)
repositories = client.repositories.map(&:full_name).select{|repo| repo.start_with?(ORGANIZATION_NAME)}
pull_requests = repositories.map do |repo|
#Get pull requests
client.pull_requests repo, PULL_REQUEST_OPTIONS
end.flatten.select do |pr|
#Filter pull requests
pr if pr[:user][:login] == USER_NAME && pr[:created_at] > FILTER_AFTER
end.compact
puts "You have #{pull_requests.count} pull requests:"
pull_requests.each_with_index do |pr, index|
puts "\t#{index}. #{pr[:title]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment