Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vindia
Created May 11, 2012 16:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vindia/2660848 to your computer and use it in GitHub Desktop.
Save vindia/2660848 to your computer and use it in GitHub Desktop.
Fetch username of person assigned to GitHub pull request
require 'json'
require 'open-uri'
user = 'GITHUB_USERNAME'
pass = 'GITHUB_PASSWORD'
repo = 'user/repo'
pulls = JSON.parse(open("https://api.github.com/repos/#{repo}/pulls", :http_basic_authentication => [user, pass]).read)
pulls.each do |pull|
issue = JSON.parse(open("https://api.github.com/repos/#{repo}/issues/#{pull['number']}", :http_basic_authentication => [user, pass]).read)
if issue['assignee'].nil?
message = "is not assigned to anyone yet"
else
message = "is assigned to #{issue['assignee']['login']}"
end
puts "##{pull['number']} ('#{pull['title']}') #{message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment