Skip to content

Commit

Permalink
Allow team_prs.rb to accept multiple orgs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpenny committed Oct 25, 2024
1 parent c1797b5 commit 714823a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export GITHUB_TEAM=<org/team>
./team_prs.rb
```

This will output all open PRs for members of the team, for repos that are in the `org`
This will output all open PRs for members of the team, for repos that are in the `org`.

The `GITHUB_TEAM` value may be a comma-delimited list of teams.

---

Expand Down
28 changes: 18 additions & 10 deletions team_prs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,45 @@
end

if ARGV.length > 0
team_name = ARGV[0]
team_names = ARGV[0]
else
team_name = ENV["GITHUB_TEAM"]
team_names = ENV["GITHUB_TEAM"]
end
if ARGV.length > 1
extra_filters = ARGV[1]
else
extra_filters = ""
end

parsed_team = Github.parse_org_and_team(team_name)
team_members = []
orgs = []
team_names.split(",").each do |team_name|
parsed_team = Github.parse_org_and_team(team_name)

team = Github.team_members(parsed_team["org"], parsed_team["team_name"])
if team.nil?
$stderr.puts "Team [#{team_name}] could not be found"
exit(3)
team = Github.team_members(parsed_team["org"], parsed_team["team_name"])
if team.nil?
$stderr.puts "Team [#{team_name}] could not be found"
exit(3)
end

team_members |= team

orgs << parsed_team["org"].downcase
end

puts "┌" + ("─" * 79)
puts "│   "
no_prs = []
team.each_with_index do |member, i|
prs = Github.open_pull_requests_for_author(member["login"], extra_filters).reject { |pr| pr["owner"].downcase != parsed_team["org"].downcase }
team_members.each_with_index do |member, i|
prs = Github.open_pull_requests_for_author(member["login"], extra_filters).select { |pr| orgs.include?(pr["owner"].downcase) }

if !prs.empty?
Github.puts_multiple_pull_requests(prs, { prefix: "│   " })
else
no_prs << member
end

if !prs.empty? && i < team.size - 1
if !prs.empty? && i < team_members.size - 1
puts "│   "
puts "├" + ("─" * 79)
puts "│   "
Expand Down

0 comments on commit 714823a

Please sign in to comment.