Skip to content

Commit

Permalink
Display pull requests for external contributors w/DCO emails.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed May 27, 2024
1 parent 55dd99a commit fc0bdab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
28 changes: 19 additions & 9 deletions bin/commands/contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Bin
class Commands
extend GitHub::RateLimited

desc 'Data about contributors.'
command 'contributors' do |g|
g.flag %i[page], desc: 'Size of page in days.', default_value: 7, type: Integer
Expand Down Expand Up @@ -51,16 +53,24 @@ class Commands
c.action do |_global_options, options, _args|
org = GitHub::Organization.new(options)
GitHub::User.wrap(GitHub::Data.external_data) do |contributor|
puts "https://github.com/#{contributor.login}"
company = contributor.company&.strip&.gsub("\n\r ", ' ')
puts " #{company}" unless company.blank?
bio = contributor.bio&.strip&.gsub("\n\r ", ' ')
puts " #{bio}" unless bio.blank?
prs = GitHub::PullRequests.new({ org: org.name, status: :merged, author: contributor }.merge(options))
prs.each do |pr|
puts " #{pr}"
rate_limited do
company = contributor.company&.strip&.gsub("\n\r ", ' ')
bio = contributor.bio&.strip&.gsub("\n\r ", ' ')
prs = GitHub::PullRequests.new({ org: org.name, status: :merged, author: contributor }.merge(options))
email = prs.map(&:dco_signers).flatten.reject do |s|
s.email.ends_with?('@users.noreply.github.com') ||
s.email.ends_with?('@amazon.com')
end.first
puts "https://github.com/#{contributor.login}"
puts " #{email.name} <#{email.email}>" if email
puts " #{company}" unless company.blank?
puts " #{bio}" unless bio.blank?
prs.each do |pr|
puts " #{pr}"
end
end
puts
rescue StandardError => e
puts "https://github.com/#{contributor.login}: #{e}\n"
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/github/pull_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ def short_url
html_url.split('/')[4..].join('/').gsub('/pull/', '#')
end

def repo_url
repository_url.split('/')[4, 2].join('/')
end

def dco_signers
commits.dco_signers
end

def commits(options = {})
@commits ||= GitHub::Commits.new($github.pull_request_commits(repo_url, number, options))
end

def to_s
"#{html_url}: #{title} - [@#{user.login}]"
end
Expand Down

0 comments on commit fc0bdab

Please sign in to comment.