-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-emails.rb
33 lines (29 loc) · 889 Bytes
/
git-emails.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'json'
require 'uri'
require 'pry'
require 'pp'
require 'net/http'
user = ARGV[0].to_s
emails = {}
uri = URI("https://api.github.com/users/#{user}/repos")
res = Net::HTTP.get_response(uri)
if res.is_a?(Net::HTTPSuccess)
JSON.parse(res.body).each do |repo|
commits_uri = repo["commits_url"].split("{").first
uri = URI(commits_uri)
res = Net::HTTP.get_response(uri)
next unless res.is_a?(Net::HTTPSuccess)
JSON.parse(res.body).each do |response|
email = response["commit"]["author"]["email"]
name = response["commit"]["author"]["name"]
emails[email] = name
email = response["commit"]["committer"]["email"]
name = response["commit"]["committer"]["name"]
emails[email] = name
end
end
else
puts res.body
puts "Error making request"
end
pp emails