Created
August 23, 2018 08:05
-
-
Save frbl/51e38a312ebddca861bebc87241dd12e to your computer and use it in GitHub Desktop.
See all PR's on github that are assigned to you
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/var/www/rvm/rubies/ruby-current/bin/ruby | |
require 'httparty' | |
GREEN = '1;32m'.freeze | |
YELLOW = '1;33m'.freeze | |
RED = '1;31m'.freeze | |
current_user = 'frbl' | |
res = HTTParty.get( | |
'https://api.github.com/issues', | |
headers: { | |
'Authorization' => 'token $GITHUB_PA_TOKEN', | |
'User-Agent' => 'Awesome-Octocat-App' | |
} | |
) | |
res = JSON.parse(res.body) | |
my_issues = [] | |
my_pull_requests = [] | |
res.each do |entry| | |
is_assigned = entry['assignees'].any? do |assignee| | |
assignee['login'] == current_user | |
end | |
next unless is_assigned | |
next my_issues << entry if entry['pull_request'].nil? | |
my_pull_requests << entry | |
end | |
# my_issues.each {|elem| puts elem['title'] } | |
if my_pull_requests.empty? | |
File.delete('/tmp/a2m') | |
exit(0) | |
end | |
my_pull_requests.map! do |elem| | |
pr = "\033[" | |
pr += GREEN | |
pr += "PR #{elem['number']}:" | |
pr += "\033[0m" | |
pr += "\t\t #{elem['title']}\n" | |
pr += "\t\t #{elem['pull_request']['html_url']}\n" | |
pr | |
end | |
File.open('/tmp/a2m', 'w') { |file| file.write(my_pull_requests.join) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment