Skip to content

Commit

Permalink
Display pull requests for external contributors.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed May 25, 2024
1 parent 41c5116 commit d3cd81a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
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

0 comments on commit d3cd81a

Please sign in to comment.