Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display pull requests for external contributors w/DCO emails. #88

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading