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. #86

Merged
merged 1 commit into from
May 27, 2024
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ Specify multiple repos.
./bin/project contributors list --org=aws --repo=aws-cli --repo=deep-learning-containers
```

Display pull requests for external contributors.

```
./bin/project --quiet contributors prs --from=2021-03-14 --page=365
```

#### Pull Requests

Show a list of pull requests.
Expand Down
21 changes: 20 additions & 1 deletion bin/commands/contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Commands
end
end

g.desc 'Create a list of all DCO signers'
g.desc 'Create a list of all DCO signers.'
g.command 'dco-signers' do |c|
c.action do |_global_options, options, _args|
org = GitHub::Organization.new(options)
Expand All @@ -45,6 +45,25 @@ class Commands
end
end
end

g.desc 'Display pull requests for external contributors.'
g.command 'prs' do |c|
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}"
end
puts
end
end
end
end
end
end
4 changes: 3 additions & 1 deletion lib/github/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def self.wrap(collection)
rate_limited do
collection&.each do |obj|
rate_limited do
result.push(obj.is_a?(Item) ? obj : new(obj))
item = obj.is_a?(Item) ? obj : new(obj)
yield item if block_given?
result.push(item)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/github/pull_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def query(options = {})
'is:pull-request',
'archived:false',
options[:status] == :merged ? 'is:closed' : 'is:unmerged',
options[:status] == :merged ? "merged:#{options[:from]}..#{options[:to]}" : "created:#{options[:from]}..#{options[:to]}"
options[:status] == :merged ? "merged:#{options[:from]}..#{options[:to]}" : "created:#{options[:from]}..#{options[:to]}",
options[:author] ? "author:#{options[:author]}" : nil
].compact
).compact.join(' ')
end
Expand Down
Loading